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
- How can I create a meta_query with an array as meta_field?
- Query multiple meta key values?
- Is there a way of increasing the speed of this query?
- How can I query all users who registered today?
- Reversing the order of posts AFTER the query is performed
- what are the numbers between curly brackets in search query
- How to get link and title of next and previous post on single page
- Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)
- Search custom post type by meta data
- Multipart/formatted MySQL query problem
- Problem with ‘post__not_in’
- Remove [gallery] shortcode altogether
- query multiple taxonomy and show post count
- Categories and products in random order
- Custom Permalinks Break Search Pagination
- add_query_arg() XSS Vulnerability
- How to Loop within a Loop (Display Children and then Grandchildren)
- How can I get all posts data from within a paginated search result?
- How to output different posts per page?
- Custom posts per page does not work with pagination
- Change searched term
- Query Posts By Post Publish Date, but sort by Custom Meta Key
- MySQL variable in query
- How to execute a SQL-query which contains multiple queries using $wpdb->query?
- Only show upcoming event or current events
- Is it possible to have pagination with an offset loop?
- WordPress pagination with get_posts?
- Why a URL with a query is always slower than that without a query?
- Maintaining Queries in URL
- How to orderby multiple meta fields with another meta query
- How to fix pagination for custom loops?
- Query posts using meta_key
- Modify users.php query with multiple taxonomies
- How to display posts by vote count and if no value continue with latest posts with no votes?
- MySql Query very slow
- posts_per_page option limits the number of Gallery items
- How to paginate information obtained from a query to a custom table?
- How to change the amount of posts previewed on a page?
- How to get events using multiple custom meta fields?
- Why in this archive page that call query_posts() function show only the last 10 posts?
- How to give classname to post if post has no content?
- Random Page Rewrite
- Notice thrown when creating numeric pagination on custom query
- How to pull posts into two columns with different image sizes using $counter variable?
- Select column name dynamically mySQL Query
- Can I use WP_Query one time and then filter the results multiple times
- WordPress Mysql query and Duplicate
- Pagination linking to first page
- Best Query for blog posts
- How to “orderby” the first array in a meta_query that uses multiply keys?
- Sticky posts limit query and pagination for a custom post type
- Why does my WP_Query pagination on a custom page.php only loads the homepage?
- Order posts ascending from posts in array
- Display data from phpMyAdmin with WordPress
- How can I get posts by 2 meta keys, prioritising one of them?
- Show 5 posts and than 3 posts offset with pagination
- Creating a Back button on detail post page to go back to blog page with same query strings and page id
- Merge two queries and remove duplicate
- WP search exclude last letter from string
- Are there any best practices for creating a Like/Favourite feature in WordPress using custom MySQL tables and without any plugins?
- Query reversed when I use “category__not_in”
- How to reduce the load / no of queries on MySql Database
- $query->set( ‘post_type’, ‘post’ ); not working
- How i make a custom sql query for Woocommerce
- Custom pagination (Title, date and teaser)
- Display result from custom post meta query
- Show certain number of post from tags
- Include custom table in query
- How to fix this insert? Don’t work for me!
- Display Upload Author & Get Uploaded Post ID
- Display list of most recent grandchild (third tier) pages
- How can I display a number to represent the order of post?
- Ordering posts alphabetically by meta keys and title
- Update vs Insert logic but the last key is always inserted?
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- Wpdb generates too many queries
- Custom Query for searching through custom fields
- Pagination not working with custom loop
- Paginate WordPress Category Pages
- Query posts alphabetically within this function
- Pagination in category.php not functioning
- query posts only works on the first page
- Custom Query for wp_posts using wp_postmeta
- WP Query outputs three items within a div
- How do I troubleshoot Maximum execution time of 60 seconds exceeded in updating a Media File?
- update $wpdb one query
- Admin Post List table Query filtering “WHERE” for custom post type
- How to use a dynamic term id for the query block