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
- Media library – Limit images to custom post type
- group search results by post type?
- How to use a custom post type as front page?
- Query by 2 values of a repeater ACF field
- Fix custom query pagination without changing site-wide posts-per-page settings
- Randomly placed sticky custom posts complemented by blog posts
- Get Custom Field Values by Another Custom Field in WordPress
- Displaying custom posts only if custom meta box’s date is not expired
- Integrating Orbit slider into wordpress through custom post type
- WP_Query | ‘post_type’ doesn’t work
- Filter by custom taxonomy slug on a custom post type
- Create 3 Level Relations with ACF and WordPress
- Change or update WordPress loop based on dropdown selection
- Can I create a loop with multiple post types and specify different $args for each post type?
- How to: Display ACF [fields] on Custom Post Types Utilising WordPress ‘Hooks’? [closed]
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- How to display all posts from standard posts to custom post types in a loop with pagination?
- Retrieve value of a category’s custom field
- Cluster CPT posts to users based on ACF value from their profile on dashboard
- ACF Values Don’t Show After Import Unless I Edit/Update Post
- Stuck in Order by more then one
- Shortcode not working with post counter
- Query Custom Post Type Taxonomy term with multiple parameters
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Get custom post type’s fields in a while loop as variables
- Integrate Custom Post Type Events into Calendar
- pagination not working for category.php (custom post types in categories)
- Query based on custom fields start and end date
- Custom Post Type single.php template only shows the latest post
- Why is my WP Query not returning first result’s post meta?
- Tag page only display 10 posts
- get_post_type is always post
- How to get a custom type post data when it has a connection with another custom type post?
- List of users that clicked a ‘Join’ button at single post
- 3 random images from custom post type, each in a div with a diffrent class
- Displaying multiple post types on home page
- Shortcode leaves no space for other elements?
- set_query_params using custom params defined in functions file?
- How to define the template for custom posts?
- Query entries from custom post type in an ACF flexible content field
- Query to get child pages of current page and display it in action hook
- Get post format
- How to export custom post type with ACF to individual file with automation?
- Display post from custom post type
- WordPress giving a 404 page when passing a year argument different than the current year
- Add Class according to the order of appearance
- Permalinks for single-[custom-post-types] not working
- Custom field with Types: get custom field’s value label (of type select)
- Drop down list with posts within the “add new” page
- How to show custom post type on homepage and in categories
- using the loop in custom meta is messing up ‘add new’ post type
- Custom archive page for custom taxonomy and pagination issue
- Update query based on CPT / Post Type, show all sorted by date
- Create if else for post types in WP_Query ‘post__in’ values
- CPT email notification including only new value custom fields
- How to avoid duplicate posts queried from custom meta?
- Why do my custom post type show up in all pages?
- Save_post acf data not updating category of post type
- Looping to organize and display custom posts by category using PHP and WordPress
- Display Specific Posts at Start of Loop
- How to display custom post type pagination buttons when processing AJAX request
- Pagination for a cpt filtered with a category
- My post loop needs to have 8 different post templates
- Mix Facebook and Twitter feed into custom posts
- CPT: execute code after load if parameter is set
- ACF Post Content Not Being Searched
- Infinite scroll doesnt work
- Excluding category from loop not working
- Group/list/sort custom post type posts by date in tabs from acf datepicker field
- Strange behavior on WP_query
- How to check if meta box value is false for all posts then do something based on that
- Custom taxonomy page template
- display news with pictures 3 small and one large (loop)
- Display posts from category in page
- Multiple Queries and Loops within CPT Archive
- Pagination not working with custom loop
- Display multiple custom post type lists on homepage – multiple loops
- Query Custom Post Type by Tag
- Loops running into each other
- Display by tag from different post types
- Loop doesn’t work in single-product.php page but works at normal page
- How to I add count of custom posts listed in a post as a prefix to its title