Looks like you’re not resetting your query, so WordPress is running a new query on the posts you already got.
After your first query add:
wp_reset_query();
Always reset after any query that isn’t The Loop.
Here’s the codex page on it: http://codex.wordpress.org/Function_Reference/wp_reset_query
Related Posts:
- WordPress Paginate $wpdb->get_results
- Custom Search Query
- When adding a custom REST endpoint, where do you put the endpoint function, and where do you put the function registration call?
- Getting $comments outside the comment template
- Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123
- Retrieve and display data from custom db table in admin area?
- How wp_ajax_nopriv since WordPress 3.1
- How to find if a post with custom_field == X exists?
- Custom search page and search by title, content and tag
- Modifying loop on a custom page, strange behaviour
- How to use get_option() without any filter?
- Custom Login and Registration form in Ajax
- Calling a php file from a javascript file in wordpress
- How I display post of the post type group by year of post?
- Hi, I wanted to make custom search with multiple fields
- Viewing checkout page removes fees from mini cart
- Load MediaPlayerElement after Infinity Scroll loads more posts
- $wpdb->replace: WHERE?
- How can I display a PHP foreach loop’s answers by AJAX
- wp_query get post custom taxonomy in search.php
- Order posts with a custom field but also without
- Save title as custom field on custom post type
- Dynamically switch template on click
- Add content in between of foreach
- Custom Loop Query For Search Page
- Custom SELECT Query With Multiple Meta Values (Ordering Problem)
- WordPress : using AJAX to get posts & Sidebar Content to an external application
- More tag – how do I remove preceding ?
- Query for specific custom field
- Display posts by combining multiple meta key
- Custom select query two tables by a meta key
- Custom Same Page Search
- Fatal error Call to a member function insert() on a non-object [closed]
- custom user meta query
- Recent activity query WordPress
- How to query term_id of a Custom Taxonomy by name
- WP Search Form Query: Add Author’s posts into search query
- query variables for custom taxonomies
- display text generated via custom get query string
- mailchimp integration on a custom footer
- Custom query pagination with php parameter as arg problem
- POST 429 Error when trying to place more than 20 images into post at once
- How to automatically pull an information from a form field onto an other page?
- How to submit form data in the same page in WordPress without reloading the page?
- Query Posts to display all posts with category “custom field value”
- Query 1 custom post type, each day, alphabetically
- Define excerpt length by inserting read more tag
- Multiple Taxonomies Using Custom SQL Query
- Unable to show messages using ‘admin_notices’
- Search a meta field for a value in all posts
- Custom WordPress SQL Query 4 posts per custom taxonomy
- Custom MySQL query to list post
- Custom Query Arguments
- Custom Query for Taxonomy
- Include plugin´s table in custom query
- User Query Multiple Orderby Clause
- Advanced Custom Fields in WP_Query: Href Returning Empty
- How to: Easily Move a WordPress Install from Development to Production?
- Is there a flowchart for WordPress loading sequence?
- Essential technical features for high-end WordPress web hosting? [closed]
- How to remove admin menu pages inserted by plugins?
- How to put logs in WordPress
- How to get the Date Format and Time Format settings for use in my template?
- What SQL Query to do a simple find and replace
- Where are Additional CSS files stored
- Best Practices for Regression Testing WordPress Websites?
- Remove wrapping div and ul from output of wp_nav_menu
- What Is The Use Of map_meta_cap Filter?
- get post author id outside loop
- Custom Walker: how to get ID in function start_lvl
- Creative uses of WordPress [closed]
- How to *remove* a parent theme page template from a child theme?
- How do I make my child theme re-apply the settings that were customised when its parent was active?
- Multiple Inputs in a Customizer Control
- New WP_Customize API – how does it work under the hood?
- Embedding a SOAP Client into a WordPress Plugin?
- Is there anything that Joomla or Drupal can do that can’t be done in WordPress? [closed]
- Update widget form after drag-and-drop (WP save bug)
- Data sanitization: Best Practices with code examples
- How to benchmark a WordPress installation? [closed]
- Should I delete the default themes?
- Moving WP install from local to live, what about wp_posts GUID?
- Modified wp.media.view.Settings.Gallery in Backbone JS, but editing doesn’t work
- Running Gutenberg React in Development Mode
- Prevent WordPress from automatically installing a new theme each year
- Can we use one WordPress installation for multiple databases, domains and content directories
- Is there a blank theme framework compatible with WP 3.0? [closed]
- Plugin SVN & update API – how are plugins identified?
- Users with custom roles not showing in post author select box
- How to use more than 256MB of memory in the admin?
- How do register_sidebar() and get_sidebar() work together?
- How do you get formatted content of a post using the WordPress API?
- Localization: I want the backend: english and frontend in defined language
- Are there any forks of WordPress (and what is different about them)?
- How to Change 404 page title
- Make Custom Metaboxes Collapse by Default
- Custom maintenance page
- Add button to TinyMCE bar without creating a plugin
- Why do I get the timeout warning?
- How to add a new product type on woocommerce product types? [closed]