wordpress get post meta custom post type: Smart way

wordpress get post meta custom post type: Smart way

WordPress tutorial for, wordpress get post meta custom post type smartly. The get_post_meta method is very useful in wordpress. here is simple code snippet.

wordpress get post meta custom post type

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.

wordpress get post meta custom post type: Smart way
wordpress get post meta custom post type: Smart way

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.