I would not do it this way, but it should not be a problem. When your template file is executed the “real main loop” already contains the posts for this page. You then execute query_posts()
to do a second query, which “hides” the “real” loop, but after you are done you execute wp_reset_query()
which makes the “real” loop again the active loop.
It would get confusing and lead to errors if you would embed the two loops, thus if you executed another query_posts()
in that main where
loop. Then you must use get_posts()
or a direct WP_Query
to prevent errors.
Personally, I never call query_posts()
myself and always use get_posts()
, because it doesn’t change any global variables “behind my back”.
Related Posts:
- Creating nested forum loops in bbPress [closed]
- How to make the following loop break/stop when it reaches 2 posts (custom post types called Topics)?
- Get post content from outside the loop
- How to split a loop into multiple columns
- Is it necessary to reset the query after using get_posts()?
- Using the Loop to show all levels of subpages under a parent page? Halfway there
- Cleanest Way to Select Every Second Element in a Loop?
- How to Change Loop to Order Posts by Views (using wp-postviews plugin)
- Get post by page name or slug
- save_post + insert_post = infinite loop
- Is `query_posts` really slower than secondary query?
- Are there any scenarios where the query_posts may be used?
- ACF Repeater loops and resets – where is the reset_rows() documentation? [closed]
- Display subpages under parent page as a list within a loop
- When to use wp_reset_postdata();
- Why do themes have `while( have_posts() )` in templates like single.php?
- What is best way passing variables to theme templates and using them different places like widgets?
- Apply styling only to first page sticky posts
- Related Posts loop – offset
- Too many nested wp_query loops in this hypothetical query?
- pop-up lighbox with AJAX
- Showing current subcategory
- Load comments per post on click with AJAX
- WordPress Loop – Style rows of posts differently
- Generating dynamic Tabs with multiple query post loop
- How do I override part of the main loop in my child theme?
- taxonomy tags 404 to custom post types
- Only display videos and images in the_content() within loop
- Recent posts on a static home page
- Query last updated posts (posts updated in the last 24 hours)
- Orderby my needs in foreach loop like by title or something?
- How to show posts with multiple tags on tag.php?
- Exclude posts from main loop based on meta value
- Using an ACF field from a page within a post loop?
- Blog page Server error 500 with stick post loop in query.php
- Show all posts using the template page and the loop?
- Why does `inclusive` not work in this wordpress loop?
- How do I automate multiple category loops?
- Change date format
- Custom loop not working
- Loop inside query
- How to stop the continuation of posts on the second loop from where the first ended
- Why isn’t my multiple loops working?
- How can I display other user avatars on an author profile page?
- something strange is happening to my code
- How to modify search.php to not show pages only show posts
- facebook like, tweet and google+1 buttons inside the loop on home, archive and search pages and missing facebook like buttons
- Loop Offset for tag based “Related Posts”
- Show articles in Pair
- How do I put my frontpage featured image in a page template for home.php?
- Randomly display post based on meta value. (Kind of Priority/Weight)
- Make a loop to return x number of posts, but only if they have content or excerpt
- Closing the loop…featured image variable based on post id
- How do you stop the rendering of the website to have something display on the front-end?
- How to print redux gallery feilds id? [closed]
- add_action in the loop hooks
- How to render the single post template with the post name?
- Reset Loop get_posts();
- static page with multiple loops breaks post pagination
- new custom theme – posts displaying on top of one another
- Offset Loop by 1 , Limit next loop to 1 (Most Recent) Post
- Help with if and else statement
- Building a form with WordPress, and also pulling that data for a user page
- How to show multiple attachements together with Scribu’s Posts 2 Posts connector?
- Database query and get_user_meta return incorrect data
- Need to while loop and display contents in the subfield of a group field given by ACF
- How to display a loop of custom post types in columns
- is it bad to copy the loop for a template?
- I want to load post in bootstrap Modal dynamically
- Why my loop is repeat?
- Excerpts not showing on main page
- dispaly all hierarchical post types from a taxonomy
- WordPress Modal showing posts not working properly
- Query posts and display all dates in repeater field in chronological order
- How to display just video post format?
- Is it possible to get a post ID of a 2 different custom post types loop embedded in the same post to perform update_post_meta from the frontend?
- Multiple loops in set intervals with code in between
- Loop shows post 5 times in a query
- Attachment Metadata inside of Loop
- Modify widget to output posts in custom order
- Make custom WordPress comments list
- Template included with plugin doesn’t return all posts for custom taxonomy
- Sorting posts to make those with post thumbnail show up first
- Best way to check if a post with specific meta exists
- Default Template infinite loop of Title
- Adding pagination to WP_Query [duplicate]
- Insert/sticky multiple posts in multiple positions
- get_posts and wp_autop (remove filter)
- Trouble preventing duplicate posts between 2 loops on homepage
- Stuck with conflicting loops on page template
- Change the way wordpress outputs images or image galleries
- How can I access ‘key’ and ‘value’ from an array in a for loop?
- How to get current page id and compare it to looped pages inside the same page?
- Show amount of posts created today above loop?
- How to create WordPress loop with combination of 4 and 2 columns twitter-bootstrap?
- posts_nav_link() not working on index.php
- How to add custom HTML markup and classes to the_content()?
- Error in Wordprewss loop for page template [closed]
- Tags outside the loop
- How to get files from loop for zip