How to output custom post type title on custom page with category next to it?

$leaderQuery->the_post() should only be called once, right after the loop starts: while ( $leaderQuery->have_posts() ) { $leaderQuery->the_post(); // call it just once … } I could also see you’re not correctly retrieving the ID of the current post in the loop, so the correct way is use get_the_ID(). $postCategories = get_the_category( get_the_ID() ); // like … Read more

Display/Filter post using if else statement

The PHP while command doesn’t work like that, it needs to start and end in the same code block. You can’t start it inside one if then end it somewhere else (although that would be nice!) What you can do is test have_posts before you start the while loop, and then keep which ever query … Read more

Display featured image of post type category

The immediate answer to your question is that you can just add a category ID to the query_posts() call, e.g.: query_posts(‘orderby=rand&showposts=1&post_type=gallery&cat=10′); Slightly longer answer is that it’s not a good idea to use query_posts in themes and plugins. More info in the docs here: https://developer.wordpress.org/reference/functions/query_posts/ You might want to take the opportunity to change the … Read more

WP_Query multiple value not working

This is waaaay after the fact, but maybe it’ll help someone else. You’re looking for an IN comparison here – where the value is IN a group of values. Here’s what it’d look like: $args[‘meta_query’][] = [ ‘key’ => ‘antivirus_antivirus_featured_scaning’, ‘value’ => [‘scheduled_scan’,’anti_spyware’,’anti_worm’], ‘compare’ => ‘IN’ ]; Read more about it here: https://developer.wordpress.org/reference/classes/wp_query/#custom-field-post-meta-parameters =]

WP_QUERY post_in problem

As documented, it’s post__in, with two underscores: $paramss = array( ‘post__in’ => array( 760, 761 ) , ‘post_type’ => ‘product’ );