In general I try to avoid custom SQL queries as much as i can and use the native WordPress functions but in some cases its much better/faster to use custom queries.
if the case is just get a list of posts the you can use the WP_Query or get_posts which will work almost as fast as a custom query (as long as you don’t need some advan
Related Posts:
- How to iterate through database until it find a match
- How do I order my loop query?
- Generating a perfect loop
- wpdb inside foreach loop only returns first result – 2 other similar cases found [closed]
- Exclude Posts Using Meta Query and User Meta
- 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
- Pagination adding extra posts only on page 2
- add_filter() doesn’t work in loop
- The Loop in Static Page
- Content/Excerpt length control for a specific loop?
- Why we use if with while loop?
- Loop posts only excluding first post
- Loop repeating design pattern
- Sort Posts By Category?
- Can’t access login screen, wp-login.php 404’s
- 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?
- 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
- 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
- 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
- WordPress shortcode in content, output in sidebar?
- Using variable in WordPress loop as criteria
- WordPress Alphabetical Sort Loop Issue
- Call wp-blog-header.php header without performing a wp_query
- Display post formats differently on index.php (loop in function)
- Get_template_part() problem with the_content()
- How to output thumbnail twice in a loop
- 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
- How to sort a loop after most viewed
- How to display fields from the loop in two separate divs
- WordPress posts loop not displaying all posts on blog
- get_page_by_title not working inside fucntions.php
- Bootstrap tabs are not being clicked in WordPress loop
- Get gallery in loop through ajax
- Get a specific size from wp_get_attachment_image_src
- Pagination on a underscore custom theme
- Build a Page which shows the Oldest Post with specific Custom Field Value
- WordPress multiple loops with default pagination
- Get top Page IDs from menu and cycle through their child pages on a scroller
- Show other category posts in single.php
- Why does it loop twice?
- Style first 3 posts differently and use a 2nd loop to get rest of posts / offset and pagination broken
- Posts Per Page is Not Returning Correct Number
- Custom Looping of WordPress Posts
- how to place Post and page content side by side
- Add specific class to featured posts
- Echo Most Recent Sticky Post in Loop?
- ACF field not appearing correctly in loop
- Posts are being displayed from old to new, in ascending order
- Loop in taxonomy for terms and post
- WordPress Tags in class
- Display articles related to a custom field on a page
- The Loop isn’t working
- Changing the loop w/o killing category links
- Custom loop page with post navigation
- Pages with a loop (index, archive) are loading the first image as post_thumbnail
- the loop – how to control whether wp or plug-in runs it
- stuck with template hierarchy
- How to create an identical second loop for attachments?
- Loop from another WP site onto mine
- Having issue with WordPress loop
- 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
- Divide loop into several columns based on post custom field and enable infinite scrolling
- Query Loop Block: possible to restrict just child pages?