While working with a variety of WordPress custom themes and building sites through WordPress system, we are often asked how to change the small text titles on the page. For example the call-center number is put on the top of the page and it has just changed, or the footer has an address or link to social networks.
There are two options to make these titles editable:
- The easiest way is to change the text in template is directly through «Appearance – Editor» section, or through FTP access, but you will need a basic knowledge of PHP and HTML codes. Which isn’t ideal, seeing as the very point of this content management system is to let you work on your websites without these skills.
- You can also create various areas (sidebars) and use text widgets for each title. This option is quite volumed and not so user-friendly. Again the HTML code could also be present in the widget code to make block looks correctly.
Which way is better? When choosing the solution of this problem, you should always first think about the usability and convenience of editing. However, users should see intuitive user interface! So, none of these options is user-friendly!
We often make experiments with different interface types while editing custom data for WordPress based sites. One of the results is Just Custom Fields plugin, which became quite popular among bloggers and developers. Now we present another plugin which we expect to be even more popular – Just WordPress Variables. This plugin allows you to create a set of text variables, which can be easily edited all in one menu. These variables can be used in a theme through special functions or in the content of your posts and pages with the use of shortcodes.
Installation:
- Download, unzip and upload to your WordPress plugins directory
- Activate the plugin within your WordPress Administration Backend
- Go to Settings > Just Variables
- Create text variables you want to edit in your theme. Press “Save changes
- Now new menu item is available Appearance > Theme Variables. Here you can set values for your variables.
- Insert special function into your theme template or insert shortcode into the post content to check that it all works fine.
Screenshots:
First screenshot: Create/edit variables page. You can create variables of two types: textbox (single line textbox) and textarea (multi-line textbox). You can also setup the default value and variables order for convenience.
Second screenshot: Variable values edit page. The main user’s menu. Here you can change the value of the text. The entered value appears on the site after you save the form (if you already pasted the special function into your template)
Variables usage:
For now the plugin supports only two types of variables usage:
Template function:
To print the value inside the template, you will need simply to insert the following code:
<?php just_variable( "code for variable" ); ?>
Note: The variable code can be found on values edit page (see screenshot below)
Shortcode:
The value output can also be inserted in post or page content, or in the content of text widget. You will need to enter the following shortcode:
[justvar code="code for variable"]
Download
Our plugin is available for download on WordPress.org plugin directory:
download Just WordPress Variables
You can also follow the development of this plugin on github.com social GIT repository (features/bugs also listed there under Issues tab)