query_posts() is going to alter the main query, and it doesn’t sound like you want that. I would recommended using the WP_Query object to get the other posts.
That said, if you must use query_posts(), call wp_reset_query() at the end of your foreach to reset your main query back to the original one.
Related Posts:
- pagination in author.php template returns 404 error
- How to display liked posts of current user in wordpress?
- Get posts by category with pure SQL query
- Query all posts and not repeat the same tag
- Using ajax with paging and a custom sub-query
- Change the destination of the URLs in post.php
- Change pure SQL database query to WordPress post query?
- My custom pagination not displaying
- My archives page won’t sort posts by month
- Pagination adds search query (again)
- How to get all images in Media Gallery with pagination?
- WordPress: paginating array using a foreach
- Trying to Add Paging to Single Post Page
- Pagination not working with custom loop
- How to Optimize WP site for millions of posts
- How many WordPress SQL Queries per page?
- Is `query_posts` really slower than secondary query?
- Are there any scenarios where the query_posts may be used?
- Advanced Custom Fields – Query Efficiency
- How do I sort multiples pages?
- How to display lastest post date in the homepage?
- how could I get the pagination as I want to when query posts using get_posts function
- Counter code for paginated category pages in wordpress
- Transient pagination not working properly
- How to tell if $query_var isset?
- Sorting Grids with Essential Grid and Events Manger
- Get the timout value of a saved transient?
- Taxonomy.php issue with search and filters
- Does meta_query work within get_posts array?
- Slow meta_query with about 4 milion record on wp_postmeta
- How do I query for a post by custom field?
- How to show more than 5 posts?
- WP Query Sort by meta value (date)
- mySQL query. ORDER BY meta_key
- Disable the MySQL query in the main query
- Strange string in console from wpdb query
- Update slug (URL) of pending posts via phpMyAdmin
- How can I get the query that would be run for the archive page?
- Query metas (and not : query posts by metas)
- Select query for a login
- What’s wrong with my $wpdb prepare?
- How can I sort homepage by a meta value?
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- Query last updated posts (posts updated in the last 24 hours)
- Exclude featured image and custom field from this get_attachment query
- wpdb print all post meta
- Different Ways to Query Custom Post Types?
- Query posts according to specific post meta values
- empty query breaks other queries
- Problem in exploding the_content to array
- Pagination for query_posts();
- What is wrong with my wp query, cant exclude the category that i want
- how to insert missing tags into the posts through mySQL?
- How to write update query in WordPress to expire transients
- Query Nickname rather than Display Name in custom Woocommerce plugin
- Get previous posts list
- how to replace old DW site with new WP site? [closed]
- WordPress SQL query to tag all posts containing a specific word on title
- Order terms by count – missing terms
- Querying Advanced Custom Fields
- How to rearrange a pool of posts joined using two queries?
- Why doesn’t my WP Meta Query return any results?
- Different layout based on post amount?
- Can I include get_posts in this array?
- Custom query Custom-Post-Types creates error
- Formatting a date/time returned from a custom $wpdb query
- Rewrite rule for query params
- Filter products on category AND tag
- Hook into the Admin Dashboard and redirect users
- Displaying data from custom table
- SEO friendly query vars
- Orderby event date (if it exists) or post date (if it doesn’t) – how to reorder posts based on meta value OR date
- Why pagination is not working with tax_query param?
- I need query_posts() to order results first by a meta value and then by post ID
- Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
- Modify behaviour of “s” parameter in wp_query
- Use WP pagination functions on a custom page template
- Pagination does not work with query_posts()
- How to make MySQL search queries with quotes
- Alternative layout the loop
- Ordering Posts by parent category, name ascending
- Pagination not working in custom post page
- Archive query not working correctly
- Custom MySQL Query for Post and Post Meta
- Horizontally paginate through sets of blog posts?
- How to fix pagination for custom loops?
- Displaying popular posts
- How to have more post in a page than in your home page
- Find all posts via SQL beginning with A of type B
- learn to run wpdb class
- Adding Category Argument into an Array for WordPress Query
- Display old posts if no future posts exist
- how to add a read more button to my blog page?
- How to add multiple values with add_query_arg?
- Limitless amount of posts in custom archive page
- 3 queries to update WordPress
- ‘Active lotteries’ only custom query for woocommerce lottery plugin and elementor
- Prevent executing query for wp_global_styles
- is it possible to get a list of URLs from post_content directly in a mysql query via phpadmin?
- Modify WordPress Search