So, in researching your issue, I stumbled across another answer on WordPress StackExchange here: Resetting post data to previous loop in nested loops
But to solve your problem specifically, you need to reset your first WP_Query’s specific post data after your 2nd WP_Query is complete. Also, you should only need to reset the postdata if you are within your if statement, not after it:
Replace:
<?php endwhile; endif; wp_reset_query(); ?>
with:
<?php endwhile; $loop->reset_postdata(); endif; ?>
Side note: Since your second WP_Query doesn’t actually have anything to do with the first WP_Query, I would either move your second WP_Query ($custom_query) outside of the first one’s while loop.
Related Posts:
- List events by month
- Remove duplicated values from a loop
- The loop seems stuck to a single (now deleted) post
- Post loop count is not in order
- get custom post type value in header.php [closed]
- Custom Sidebar in Editor (not Widget) for Custom Post Type in Genesis
- Fetch data from two custom post types and create multidimensional array for output to html table
- Show custom post type event if current day using ACF
- Some posts not displaying by taxonomy term
- ACF meta_key and meta_value break loop
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- Display related post content and custom field content
- $post breaking container loop
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- Custom Post Type Loop breaking php
- Styling first post using Advanced Custom Fields
- Filter page ID outside the loop and order
- WordPress post objects in one parent post object
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- Posts per row on archive page (custom post type)
- How do I know the ‘meta_key’ for ordering my custom post type
- How to update post meta on uploaded image from a custom form?
- How to group posts and get a mixed posts and groups view?
- Custom Theme With Custom Loops
- Custom Post Types strange pagination problem
- Custom Post Types vs. Advanced Custom Fields (with Repeater Field add-on)
- Multiple Frontend Filters Using Advanced Custom Fields
- Integrate Custom Post Type Events into Calendar
- Specific routing for CPT
- Order post by date with ACF
- Custom post type conditional in loop
- Displaying custom field according to date
- Listing all term items alphabetically / sorting loop
- Display related custom taxonomy posts in sidebar
- How to set the seo title tag on a page by page basis?
- WebP Fallback for Inline Background Image in Style Attribute
- pagination not working for category.php (custom post types in categories)
- Adavnced custom fields relationship query plus query inside
- Query based on custom fields start and end date
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- How do I control the output of a custom post type in the loop?
- Display custom post type posts first, then default posts
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Three Most Recent Posts, One Per Term
- Targeting custom post type
- Does WP have a global of $id?
- How To Import CPT With Only Few TEXT ACF Fields From Front End?
- WordPress Loop if/else
- get_the_title() is returning results from previous loop
- Advanced custom field boolean value in custom post type
- Custom Post Loop pulling all custom posts, not just one
- Conditional for a Single Post That Belongs to a Category?
- Wrapping x posts in html without leaving empty html
- WP Query post__in not returning correct results
- Custom Post Type single.php template only shows the latest post
- Why is my WP Query not returning first result’s post meta?
- Sort posts in loop by the WooCommerce Membership of the author
- Including all post id’s of a custom post type into an array
- How to include custom post type posts on a page?
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Tag page only display 10 posts
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- Querying & displaying custom post type into an existent page [closed]
- How can I group posts by months and years?
- Pagination Error : Duplicate argument being outputted
- get_post_type is always post
- Multiple Custom Post Type queries, how to DRY it up
- Custon Content within WordPress Loop
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- Bootstrap accordion looping through posts incorrectly
- Main query not querying any posts in custom taxonomy template
- How to get a custom type post data when it has a connection with another custom type post?
- Loop increase number
- Why would social icon badges disappear after adding a custom post type?
- get_post_meta is not working inside shortcode
- Sort a custom post with ACF: Date Picker & Display Featured!
- Using wp_query to modify the loop in index.php for a CPT
- the_post() is printing titles in page footer
- ACF repeater field usage
- Custom WP_Query doesn’t display all posts
- Query & the_content() is showing in the header
- List of users that clicked a ‘Join’ button at single post
- Create Array from custom post type to display a slider
- Move Genesis Single Page/Single Post Title
- get parent content inside child posts
- 3 random images from custom post type, each in a div with a diffrent class
- Two column layout with alphabetical ordering
- Control content before and after custom post type loop
- Listing custom post types on archive page with array
- get_pagination not working on a custom post type query (using WP_Query)
- How to Make infinite loop of post
- WP_Query with custom post type ID
- Displaying multiple post types on home page
- looping though custom post types and only return results in a given taxonomy
- Shortcode leaves no space for other elements?
- How to conditionally add Custom Post Type to Front Page
- How to inherit field value from parent post into in child / sub post
- Dynamically insert code to custom post type loop