How to Get Specific Custom Field Values in WordPress
If you want to make your post display more detailed and comprehensive, or you want to exhibit it according to your requirement, then you need to have some latest updates in your WordPress.
To do this task, you have to add some lines of code or there is another option which is provided by WordPress itself in which you can get WordPress (free and open source blogging tool and a dynamic content management system) that helps you in assigning custom field values in posts. This extra information which you added is called meta-data.
This meta-data is controlled with key/value pairs. The Key is basically the name of meta-data element which can be used in more than one per post while the Value is the information which will appear in the meta-data list on each individual post.
Instructions
-
1
First of all, you need to open your FTP in order to add custom values in WordPress.
-
2
After that you have to open Public_Html.
-
3
When you have selected Public_Html, open ‘wp_content'.
-
4
Select Themes, and name it according to your choice and paste the following code in it.
< code>
function get_post_custom_keys( $post_id = 0 ) {
$custom = get_post_custom( $post_id );
if ( !is_array($custom) )
return;
if ( $keys = array_keys($custom) )
{
/*@Name:
Old: return $key;
Below code will return only the step added in , remove the extra options saved against this post.
*/
$new_keys= array();
$i=1;
foreach($keys as $step_key)
{
$step_counter= ‘Step ‘. $i;
if($step_key==$step_counter)
{
$new_keys[$i] = $step_key;
$i++;
}
}
return $new_keys;
} -
5
Once you are done with this, open post.php in which you will be able to find wp-includes folder and call the function there.