- Advertisement -
VPS House Servers
VPS House Servers
VPS House Servers

How to add custom post meta field in WordPress Theme

If you are developing WordPress Themes or starting to customize your WordPress site, you will often find, that you need a custom post meta field when you are customizing posts in WordPress Themes. It can be a simple label, text field or a more advanced one, like an option to add the widely popular Revolution Slider. The main advantage of this approach is that each post can have a unique Slider and you will save your user/buyer some time due to it’s simplicity. No more tedious shortcodes for Slideshows.

Add custom post meta field

The first step is to add an extra field in each post, through which will the user choose the appropriate Slider.

Open the file function.php in theme’s directory and add the following code which will create the extra field.

We just need to take care of saving the choice of appropriate slider.

- Advertisement -
VPS House Cloud Servers
VPS House Cloud Servers
VPS House Cloud Servers

Our new field is now added and can be seen in each post in your WordPress Theme. User can now select a Revolution Slider, unique to each post

custom-post-meta-field-in-Wordpress

But how to call this field in the post itself? This is the last thing we have to add, to make this working. Open the PHP file which contains your code for the post (like single.php for instance). Add the following code:

Custom post meta field is now added to your WordPress Theme and users can set a unique Revolution Slider for each post. Code will probably have to be adjusted a bit, since each Theme has it’s own hierarchy and rules.

- Advertisement -

There are no comments yet

  • Hello, guest