Sorry for the delay. Apparently, I was not yet subscribed to this forum.
I tested with posts, pages and products because that’s what I had available and it works just fine.
$args = array(
'post_type' => array ('post','page','product'),
'meta_query' => array(
array(
'key' => '_featured',
'value' => 'yes',
)
) );
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
Don’t forget that by default the query will not show ALL of the featured posts, but will only get the first 10, or however many you have set in the “posts per page” setting. Therefore if all you have 10 or more featured posts and pages, more recent than your featured newsletters you’ll never see any newsletters show up in your above query.
Thread Starter
horria
(@horria)
Thanks for your reply.
Unfortunately I’ve tried with your code and the problem is the same. It displays post and pages OR newsletters, but not all 3 at the same time.
I’ve checked posts per page and also many other settings, also reduced the query to a minimum but problem persists
I’m sorry you can’t get it to work. But since this is an issue with your query maybe you should try re-posting in the regular forums or at WordPress Answers.
Something must be interfering with the query, so I would suggest disabling other plugins, switching to the default theme, verifying that you have a very recent featured “newsletter”, and double-checking how the newsletter post type was registered (public, queryable, etc).
Thread Starter
horria
(@horria)
Ok I will try, thanks for your reply.