I finally figured this out. It’s simple, too.
As I posted it, that loop would never finish because there’s nothing advancing the counter inside the while loop.
But if I uncomment my fairly normal-looking code and run it, it still wouldn’t close, because I’m not advancing the specific Query object’s counter. When you run the_post()
, it advances the counter inside the global loop object and sets the global $post object, which is what will be run when you call functions like the_title()
and others. So you’d run through every post in the database, because though my custom $home_gallery
query object only had 5 posts, the global loop has all the posts in it.
In other words, since I didn’t specifically run $home_gallery->the_post();
, everything exploded.
Hope this helps someone else.
Related Posts:
- How do I get the attributes of a short code from a post?
- WordPress category & taxonomy loop with pagination
- Changing behavior of the loop twice in one page
- Show scheduled posts in archive page
- post__in – Placing content from a foreach loop inside of an array
- loop query exclude meta_key with meta_value
- “Blog pages show at most” in The Loop
- wp_insert_posts Fatal error: Maximum function nesting level of ‘100’ reached, aborting!
- Post Loop not Returning Permalink
- Displaying child page content of a certain parent
- Custom page template
- Get posts that matches specific terms of multiple custom taxonomies
- add_filter() doesn’t work in loop
- The Loop in Static Page
- How can I use get_permalink() outside the loop?
- Content/Excerpt length control for a specific loop?
- How to check for specific content in comments in the loop
- Why we use if with while loop?
- Problem the_permalink
- Loop posts only excluding first post
- Loop repeating design pattern
- Sort Posts By Category?
- Create static front-page with 3-5 recent posts
- Customize WooCommerce Product Images (Placement and size) [closed]
- Create a loop that gets pages with their template
- Why is my loop not dynamically grabbing the correct Category and displaying all categorized posts?
- get latest 5 posts and a specific post and sort in a specific order
- How to check if a post exist?
- Query posts if meta key starts with
- 3 Posts in Loop, Show Stickies First
- Loop within a loop (Again) for template
- How to use current_post to open a new unordered list every five posts
- Why cant you place the Loop outside of the index.php?
- sticky post in custom loop
- Rating system and changing the loop
- Ajax Button to load more Posts into a timeline
- How to target thumbnails of the first post in the loop
- Infinite Scroll on a loop?
- On single.php, fetch 2 posts created after and 2 posts created before in relation to the actual post (using menu_order)
- Problem getting current post tags to show in a widget
- Post classes in the loop are being changed in certain themes
- Exclude page name from loop
- PHP if post is already displayed, then
- How to style first post differently with ‘get_template_part’?
- Include multiple page ids in loop
- in Foreach Loop the Description is not showing?
- 404 Template customization | Want 10 recent Post on the 404.php error page apart from the error Notice
- How to append a query string to pagination?
- For each loop on every word in post
- Display name of taxonomy once
- Use have_comments() for current post instead of last post in loop
- Displaying the first, second, and third posts from a category in separate slides
- Get the image src and href data from posts
- Sending mail not working correctly
- WordPress shortcode in content, output in sidebar?
- Using variable in WordPress loop as criteria
- WordPress Alphabetical Sort Loop Issue
- Get_template_part() problem with the_content()
- Multiple instances of Featured Image Thumbnail As A Background On Homepage
- Altering “posts_per_page” for defaut loop
- Why doesn’t ‘continue’ work in page?
- Fetching posts from wordpress function in ajax
- Saving return value from the_author_posts_link()
- Display more than 10 posts on author.php file
- how to run loop in function.php that sends email based on specific conditions?
- How to use this $tax_selection variable in this custom loop?
- Display all categories as plain text
- Loop info in jquery Tabs – loop into a variable?
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Several loops in sidebar issues
- Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron
- $post is undefined in wordpress loop [ajax]
- Insert content above an embedded video inside Wordress’ php the_content
- Loop two different category WP_Query
- Use ACF Category Image for all Taxonomy Archive Views
- Loop with custom posts, to include information from different custom post type
- the loop printing post in one grid
- Check value of post meta within IF statement
- My WordPress installation doesn’t load correct template
- Work arounds for conditional checks inside the loop in search.php?
- Transient not working for external data
- Get Sticky User in user loop based on user role
- Popular posts with Varnish ESI
- Querying posts from only one category and exluding the latest post
- the_title() Returns the page title instead of the post
- WP update_post_meta link loop
- How do I aproach this?(for sale, for lease, sold->move something from a category to another)
- How to fix pagination for custom loops?
- query_posts ignores the argument
- Need some help with “the_widget()” function
- show posts from one category with comments only
- Exclude Authors based off date of last post
- Loop from another WP site onto mine
- Having issue with WordPress loop
- I need to update the post query? [closed]
- Wrap every 2 divs in row – for each loop [closed]
- How to add class to the last image of the last post in a loop
- Multiple loop with pagination in same page
- Divide loop into several columns based on post custom field and enable infinite scrolling
- Query Loop Block: possible to restrict just child pages?