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
- “Page Not Found” with multiple last pages of query
- When should you use WP_Query vs query_posts() vs get_posts()?
- How to fix pagination for custom loops?
- How to display SQL query that ran in query?
- Pagination not working with custom loop
- How can I create a meta_query with an array as meta_field?
- Query multiple meta key values?
- How to Optimize WP site for millions of posts
- Wp get all the sub pages of the parent using wp query
- Get the ID of the latest post
- How to query for most viewed posts and show top 5
- How to get comments by post ID?
- WP_Query vs get_posts
- WordPress Paginate $wpdb->get_results
- Differences between wpdb->get_results() and wpdb->query()
- Is there a way of increasing the speed of this query?
- Get all image from single page using this query
- How can I query all users who registered today?
- Get Terms by IDs with IDs order
- Reversing the order of posts AFTER the query is performed
- what are the numbers between curly brackets in search query
- simple sql query on wp_postmeta very slow
- Using WordPress public query variables
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- Custom post type archive 404’s with paginate_links
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- How can I make wp-pagenavi work on a custom query built upon a form submission? [closed]
- How to get link and title of next and previous post on single page
- Create pagination and order according to alphabet
- Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)
- wpdb get posts by taxonomy SQL
- How to List Events by Year and Month Using Advanced Custom Fields?
- Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
- get_query_var(‘paged’) always returns empty
- Custom WP_Query order by post_meta and (author) user_meta
- wordpress query – orderby child post date
- How many WordPress SQL Queries per page?
- How to display Section for certain time
- Add multiple value to a query variable in WordPress
- Get the number of posts from the current page results
- Search custom post type by meta data
- Custom query_var causes displaying posts archive on front page
- Slow wp_enqueue_media()
- Multipart/formatted MySQL query problem
- What is the most efficient way of implementing a favorite post system?
- Query Custom Meta Value with Increment
- Problem with ‘post__not_in’
- Remove [gallery] shortcode altogether
- Is `query_posts` really slower than secondary query?
- Compare two numeric custom fields
- Are there any scenarios where the query_posts may be used?
- wp_dropdown_categories with multiple select
- Advanced Custom Fields – Query Efficiency
- Alter query on edit.php
- Why does get_the_time(‘F j’) return November 30 for all posts?
- Get posts by meta data OR title
- Query by one meta_key and sort by another (possibly NULL value)
- How to tune search argument in WP_Query to show only exactly the same results?
- Perform query with meta_value date
- WP_Query ordered by custom field that is a date string?
- Sort X categories by last update and show image
- Custom query filter not working on woocommerce category page
- How to delete a transient on post/page publish?
- using post__in allow duplicate post id
- Pagination on archive.php page
- Very slow query
- query multiple taxonomy and show post count
- Search Terms – Querying on either description__like OR name__like in the same Term Query?
- Query & Sort Comments by custom comment meta
- Having trouble generating pagination links on custom query
- How to get my loop to pull posts into three columns
- How do I sort multiples pages?
- How to display lastest post date in the homepage?
- Add and in the header while looping over custom query in page template
- Using dynamic conditions in ‘posts_where’ filter
- Custom $wpdb Query for Custom Post Type by Category
- How to order posts by modified date without using ‘query_posts’?
- Limit number of pages in pagination
- Get a user’s most recent post title
- How to limit search to first letter of title?
- query_posts and pagination, still stuck after much research
- Categories and products in random order
- Custom Permalinks Break Search Pagination
- 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
- add_query_arg() XSS Vulnerability
- Count user posts by user ID, Post type and Post status
- Can’t pass table to $wpdb->prepare