“The Loop” is just a name given to the while (have_posts()): the_post();
loop used to iterate over an array of posts returned by WP_Query()
. The other function used for querying posts is the get_posts() function, which returns a simple (non-extended) array which you can loop through with a foreach
loop.
I don’t think it matters a whole lot; however, if you’re nitpicking, the get_posts()
method is slightly faster and less memory-intensive, since it doesn’t call setup_postdata()
(which populates the template tags, etc.) on every post it loops through.
Either way, you’re probably going to run out of memory on some setups with thousands of posts… Make sure you build in fallbacks in that case.
Related Posts:
- Manually set global $post vars with an ID, in order to use template tags
- post expire after x days
- Recent posts per category loop?
- Import Instagram post to WordPress blog post
- Show related posts based of current ACF field name in a single page post (a loop within loop)
- Plugin is creating posts twice
- single.php fires more than once after clicking on any post to view with different post id each time
- Solutions to repost categories into multisite blogs?
- How to enable qTranslate languages tabs in custom plugin page
- How do I “get the next 10 posts after post_id == x”?
- Hiding posts – WP Hide Post not working
- Use wordpress functions in another PHP file
- submit posts by unregistered users in wordpress
- Calendar Solution: Handling upcoming Dates with Posts?
- get_post_type on post.php
- Is there an easy way to flag posts in the admin area?
- finding whether request is for post, and post id
- Any built-in function to associate a post to category through a plugin?
- How to hide some section in WordPress under Post
- Display post lists in 2nd paragraph
- Can’t delete Draft Post [closed]
- Matching Chapters to a Custom posts [closed]
- WordPress comments not appearing in blog posts, likely because of Redux template. Could I fix this with a plugin that adds a comment form as a block? [closed]
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- WordPress display breadcrumbs using Yoast plugin [closed]
- Outbound link autometic converted into linkdirect , and not opening
- Display by Category in Admin
- Preg Match All doesn’t Allow echo first character for WordPress Taxonomy Tags
- How to allow an editor to edit all WordPress blog posts but have the last say as administrator?
- Two problems on my WordPress installation [closed]
- posts comments goes to trash
- Contributive page where people logged in can write
- Excerpts on category page
- How to pull email and name from Flamingo plugin
- Insert content of a post into another
- Which widget to use for display category post with view more? [closed]
- External RSS feed to WordPress Portfolio
- Trying to fix form resubmition with PRG (Getting error: Cannot modify header information – headers already sent by)
- Problem with the Loop – want to limit the access to three free articles
- Display wordpress post’s in popup?
- Unable to add TAB character to post?
- how to add text to posts from tags
- Add category selection to custom post type (plugin)
- Redirect to another page using contact form 7? [closed]
- Would Gutenberg be considered a PlugIn?
- pagination on data fetched using SQL query
- WordPress Plugin manipulate have_posts()
- How to delete all trashed item in one-go
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- Get User_id outside wordpress,
- How to get the first post and second post in a wordpress blog?
- Is it possible to send blog posts via email to subscribers?
- Custom setup of wordpress comments that are displayed
- Is there any plugin which can paste a common content to my every post?
- Calling the_excerpt from inside a plugin template file
- ‘Organize Series Plugin’ as muti author feature
- Problem of encoding characters (apostrophes) in my posts publications
- How to backup single post in wordpress [closed]
- Bulk update wordpress posts
- How to get a list of bundled products using wp_query in woocommerce
- How to get all posts belongs to a user between a certain date
- Where to find the code used to render a page that has a shortcode and a template defined?
- How do I publish portfolio items with a future date?
- wordpress content .php file in an iframe’s src in a wordpress post
- Making my plugin create a page?
- Is there a way to make the main page only display a brief description of the full article?
- How to change the post form from plugin?
- WordPress plugin Post Creation [closed]
- Don’t publish/update a post when a plugin finds errors in custom fields
- Allowing users to Sign-up > Login > Post articles that need approval
- How can I automatically download all images from all imported posts, place them on my new host, and replace all the links
- posts from multiple post types in one slider
- How to display the featured post on the category page?
- Loop in elementor custom widget not working
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- get_users(); Is an Undefined Function When Used in Cron Job
- Flickering sidebar when scrolling page [closed]
- Is there a plugin or a way in the wordpress that would let us have different versions of a post or page accessibe to users?
- Moving FB comments at the end of page
- Where Should i write the code for wordpress ajax voting?
- download button for audio file in post [closed]
- check uncategorized category by default
- Print posts category or tag as a formatted journal
- Trying to add_action in a loop
- how to execute some code after a post is published in WordPress [duplicate]
- Loop returns the current page’s permalink and guid instead of the post in the loop
- Post status doesn’t update to ‘future’ every time?
- Function added to hook “new_to_publish” not executing – custom plugin
- Creating an admin meta box to save post as pending
- trigger email when post is published by someone a user follows
- Grab ID from post from plugin and use it to create an object
- Get post content from outside the loop with plugin shortcode usability
- Article content navigator in wordpress like mbaskool website
- WP::is_main_query() Not Working
- I would like to remove date display on photo preview
- Post deleted in trash [closed]
- Getting a list of the published posts
- How to relate 3 wordpress components with each other (Create database relationships)
- Change website directory safely to add a static page on startup
- Price comparison table based on Custom Post Type?