To get post meta fields, you can use get_post_meta()
function, but obviously not get_user_meta()
, the name of the functions are self-explanatory.
The first parameter of get_post_meta()
function is the post ID; here you define which post you want to get postmeta from. So, you need to get frist the post ID of the post you want and then pass this ID to get_post_meta()
.
For example, you can get the posts from author with ID 5, limit to “product” post type and then get the post meta for each found post. For example, using get_posts()
:
$args = array(
//Get all posts from author 5 and post type "product"
'author' => 5,
'post_type' = 'product',
'posts_per_page'=>-1
);
$posts = get_posts($args);
foreach($posts as $post) {
get_post_meta($post->ID, 'lt_content_design', true);
}