You need to call wp_reset_postdata()
after a secondary query to restore the global $post
to its original context.
Related Posts:
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Is it possible to create a shortcode that will query a post based on taxonomies?
- WP_Query is printing out only one post when posts_per_page is set to multiple
- Get custom posts with certain ids in a custom loop using a shortcode
- Custom Post Type Loop within Shortcode
- wp_reset_postdata() and wp_reset_query() inside shortcode are not working to reset original page query
- Shortcode with WP_Query more than once on one page
- Alike Shortcode using in Custom Shortcode
- Modify shortcode to work with custom taxonomies and slugs
- Shortcode display CPT Query only showing 1 post?
- shortcode for recent custom type post
- Adding custom shortcode to page leads to page without styling
- 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 make a WP_Query search with custom post types?
- Create a shortcode to display custom post types with a specific taxonomy
- Add Content to Page without shortcodes
- how to filter by last name for custom post
- The Operator “NOT IN” Does Not Work In tax_query
- Display Custom Post Type Fields
- How can I fix those issues generated by the Themecheck plugin
- How to get_queried_object on multiple objects?
- How to get the parent’s taxonomy?
- WordPress query by multiple Custom fields and order by date
- Help with hierarchical custom taxonomies and permalinks…almost there
- New WP_query in template not working with CPT+category on some pages
- Displaying a specific post in a wp query by post id
- Query current and future events, ordered by begin date
- Query custom post types and a specific page?
- Optimised Code for Pulling Taxonomy Posts
- Calculating Bayesian average for custom post type
- How can I get the first 50% of all posts (within a custom post type)?
- Remove duplicated values from a loop
- is there a way to retrieve posts that do not have a featured image assigned?
- Related posts in all categories of current post (custom post types)
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- shortcode to show custom post types by category
- Genesis filterable portfolio isotope [closed]
- convert custom query to wp_query
- Get custom taxonomies from multiple posts
- Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”
- Custom post ui plugin & WP_Query – Polylang
- How to use load more custom post type data normal or according to on click category tab In WP
- Display Child Pages of Custom Post Type Parent Page
- Shortcode to display Staff post type based on Location post type and Specialty post type
- Problem: wp_query outputs all images on site
- Foreach inside shortcode not working as planned
- How does order=asc effect a wp_query (its acting pretty weird in a loop)
- Using wp_query to modify the loop in index.php for a CPT
- Wp Query with multiple custom tag(taxonomy) by get the terms
- Pagination not working on custom query on a page
- Query within a foreach within a query (queryception)
- how to create custom post type with dynamic category_name using shortcode
- WordPress Custom Post Type and Shortcode for Portfolio Items
- Creating shortcode id for custom post types
- How to get Custom Post Type with Categories wise in WordPress using wp_query
- Post ordering not working with custom field
- How to properly use Categories with Custom Post Types
- Displaying Portfolio Filter by Category Order (alphabetically)
- Custom Post Type Query W/Category Dropdown
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Pin posts to top of custom loop
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- WP_Query get always custom post_type for first
- background featured image display using shortcode
- WP_Query – How To Query Only Custom Posts With No Children of Their Own?
- Foreach result into WP_query
- Query custom post type and custom field by URL parameters
- Button link display in shortcodes using custom field in ACF
- meta query multiple values for the same key
- Custom post types – meta_query: search lesson which starts sooner
- Wp Query sort order from custom MetaBox
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- Custom Post Type Query by user id
- Query posts based on user preferences
- CPT post doesnt shows tags and category on backend admin page
- Adding a nav menu for a custom post type
- How to use costum database table for custom post type
- Most efficient way of showing children posts?
- Querying, storing, and using data from 2 separate custom post types
- date_query won’t accept day parameter, but will accept month and year for a custom post
- Custom post type and custom taxonomies display
- WordPress custom post type
- Custom Info Box at end of posts?
- Custom Post ‘Post Per Page’ Crashing Page?
- Issue with permalinks for custom post type
- Paged within a custom content type template [duplicate]
- WordPress can only query up to 766
- Custom loop won’t work, can’t find problem
- Query by post type or category
- How to exclude certain portfolios from a loop
- Rewrite a filter as shortcode (or something like that) to use anywhere in CPT
- show the most recent date of all posts to display on front end
- Display ACF object field data using Elementor Custom Query
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Default WordPress Query for a Specific Custom Post Type URL
- Sort ACF by custom taxonomy
- Dynamically count the number of custom post types associated to a custom taxonomy