You create a new query and assign it to $my_qry
, but you never loop over those results. See the codex page for WP_Query
, the loop has to reference your new query object:
$my_qry = new WP_Query($args);
if ( $my_qry->have_posts() ) :
while ( $my_qry->have_posts() ) :
$my_qry->the_post();
// etc..
endwhile;
endif;
Related Posts:
- The Operator “NOT IN” Does Not Work In tax_query
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- Combine tax_query and meta_query in WP_Query
- tax_query returning all posts instead of selective posts in WP_Query
- Query custom post type by category slug
- Custom post taxonomies as tax_query terms?
- Why is this query not working? (Standard posts + custom post type)
- Custom Widget WP_Query problem
- How to display Related Posts based on number of taxonomy terms matched
- tax_query not working in template
- WP_query – Filter by tax_query and meta_query using multiple select
- WP_Query parameter conflict
- Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
- tax_query (if the terms are empty)
- Running a custom query inside another cpt single and trying to grab a variable
- Custom Query: Multiple CPTs and a taxonomy filter
- Display related CPT with custom taxonomy
- custom post type and a “sticky” position taxonomy
- How to search through all child taxonomies using WP_Query?
- WP Query tax_query not returning posts
- Not able to get my custom search result using meta_query and tax_query together?
- Query breaking with ‘posts_per_page’ => -1
- tax_query showing no results
- Using tax_query to get single post per category
- WP Query Conditionally query meta and taxonomy
- How to use a custom post type archive as front page?
- Combining queries with different arguments per post type
- How do you get the count of posts in an archive page?
- how to filter by last name for custom post
- How to get_queried_object on multiple objects?
- How to get the parent’s taxonomy?
- New WP_query in template not working with CPT+category on some pages
- Count number of posts which exist in 2 taxonomies?
- query order by date on custom type: wrong order
- Displaying a specific post in a wp query by post id
- Query current and future events, ordered by begin date
- Optimised Code for Pulling Taxonomy Posts
- Calculating Bayesian average for custom post type
- Help with CPT template pagination
- How can I get the first 50% of all posts (within a custom post type)?
- Remove duplicated values from a loop
- WordPress theme options vs custom post types
- is there a way to retrieve posts that do not have a featured image assigned?
- How to connect two custom post types with nested loops
- Custom Post type and Custom Field WP_Query
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- How to show CPTs in term archive
- shortcode to show custom post types by category
- Query/list all terms and their custom post count
- convert custom query to wp_query
- Get custom taxonomies from multiple posts
- Pagination on with query_posts in custom post type template
- Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”
- How to use load more custom post type data normal or according to on click category tab In WP
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Using meta_query and tax_query at the same time
- Problem: wp_query outputs all images on site
- How does order=asc effect a wp_query (its acting pretty weird in a loop)
- Why is my WP_Query outputting my entries twice?
- Using wp_query to modify the loop in index.php for a CPT
- Custom WP_Query doesn’t display all posts
- WP_Query() with custom post type and taxonomy — get all terms?
- Query & the_content() is showing in the header
- Custom post types problem
- Pagination not working on custom query on a page
- Query within a foreach within a query (queryception)
- Post ordering not working with custom field
- Query custom posts from custom taxonomy
- Query Custom Post Type by Taxonomy
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Related “custom post type” using “custom taxonomy”
- I’m having trouble with Related Product “tax_query” ‘terms’ value
- How can I get custom post types to recognize pretty permalink variables?
- Cannot get to work tax_query array for terms
- Error in the page of a CPT file in WordPress
- post type => ‘any’ not applied my custom queries
- Query the title of the page to show posts with matching category in the loop
- The most recent post of custom taxonomy
- Problems with the WP_Query query for a Custom post type
- wp_query return nothing
- Main site single-property.php design, as homepage of a multisite
- Query pulling all taxonomies, not one I am specifying
- Insert single CPT items every x posts of another CPT
- Get archive of posts separated by taxonomies and subtaxonomies
- Can’t seem to filter wp_query by current category ID
- why custom post archive gives always no more than 10 posts despite of paging settings?
- WP_Query with custom post type search showing all results every time
- Post data in separate divs with incrementing class using WP_Query
- Selecting posts older than the current Unix epoch timestamp
- How to list groupings and keep pagination
- How to retrieve taxonomy terms of the current custom post?
- Change display wp post type to wp custom post type
- direct custom post query interferes with other queries on page
- Get all custom_post_type posts + blog posts from one category in a single query
- How to exclude certain portfolios from a loop
- show the most recent date of all posts to display on front end
- Adding custom theme template to custom post type [duplicate]
- Display ACF object field data using Elementor Custom Query
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Sort ACF by custom taxonomy