Query posts with custom field value
-
I have the following query
<ul> <?php $featuredPosts = new WP_Query( array( 'post_type' => 'events', 'post__in' => array(110) ) ); while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?> <li> <?php the_title() ?> </li> <?php endwhile; ?> </ul>which works well but what I would like to do is add the “post__in” contents to a custom field on the post and to add those results to the query. I’ve tried
<?php $featuredPosts = new WP_Query( array( 'post_type' => 'events', 'post__in' => array(get_post_meta($post->ID, 'custom_field_name', true)) ) ); while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>But this doesn’t return any results.
Any help or ideas would be greatly appreciated.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Query posts with custom field value’ is closed to new replies.