Quantcast
Viewing latest article 1
Browse Latest Browse All 2

Using get_post_meta in wordpress post in the functions.php file: Smart way

The get_post_meta method is very useful in wordpress

If you want to shorthand the get_post_meta call for the current post then you can use following:
you can use above method through functions.php file. You need to put following code in file:

function get_current_post_meta($key,$postID=null){
if(empty($postID)) {
global $post;
return get_post_meta($post->ID,$key,true);
} else {
return get_post_meta($postID,$key,true);
}
}

and you can call it like this:

echo get_current_post_meta('custom_tags');

Using above method you can pass the post id also.

Image may be NSFW.
Clik here to view.
Using get_post_meta in wordpress post in the functions.php file: Smart way
Using get_post_meta in wordpress post in the functions.php file: Smart way

Follow us on Twitter WordPress API


Viewing latest article 1
Browse Latest Browse All 2

Trending Articles