Why don’t you use WordPress get_posts?
You can add the parameter orderby => ‘title’ as you want.
$args = array(
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'title'
);
$posts = get_posts( $args );
print_r($posts);
If you want the sql you can just add ORDER BY post_title
:
SELECT * FROM $wpdb->posts
WHERE post_type="post"
AND post_status="publish"
AND post_title LIKE %s
ORDER BY post_title
Related Posts:
- Order post by year DESC and month ASC
- How to Display Post View Count
- Function to show random posts from a category
- Hiding posts in a list from specified categories
- Custom order for Mysql array
- While loop articles – if statement order
- How to only publish posts with image in it
- How to check in functions.php if there is data in a WP_Query?
- Get post by tag
- Query function not executed between element [closed]
- query for filtering published posts?
- How to correctly escape data
- How to limit the number of results for all query_posts on mysite
- wp trim function not working
- How to sort posts alphabetically based on a specific parent category
- Keep featured content post in homepage with original order
- How to change the case of all post titles to “Title Case”
- Display all posts from specific categories on a page
- How do I reorder (pop and push) items from WP_Query?
- How to exclude latest x posts from a paginated query?
- Display content from a specific category
- Query posts from current year
- Code to auto expire posts after 30 days
- WordPress Posts Out Of Order after 3.1 Update
- Keep a fluid max number of posts on site
- Custom colors for post rows based on post meta value
- Custom wp_trim_words() function not trimming right
- Delete Post From Front-End and attachment permanently
- Limit function to specific post category
- Insert all post IDs in new database table
- Change Order of Admin Posts Depending on Meta
- Checking is user author of number of posts?
- Create cron job without a plugin?
- Create dropdown list post
- Uppercase first sentence in every post
- How can I sort posts by the date and a custom meta field?
- Display all posts that were published before full post on single.php
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- Sort WP posts by span value
- Force the “Choose from the most used tags” meta box section to always be expanded
- How to allow users to post only in certain category and hide elements from edit page?
- How to sort posts inside categories
- Get user categories with most posts in it
- Random ajax load only works with posts_per_page set to -1
- MySql query to get posts with all meta and terms
- List authors with the last post title and order by last post date
- How to order posts by meta_value and title
- How to order posts in an arbitrary order?
- Wrong post title displayed from loop
- WordPress website loads more posts than expected
- Get the amount of posts on a current page
- query post limits
- Post type no single page
- update image path with words starting uppercase to lowercase chars
- Adding a user’s ID behind the tag ref link address
- Isn’t the way posts are displayed very unefficient?
- Post Filtering by GET URL parameters
- Related Posts function not working
- the_content() Not Grabbing All Content
- All categories displays the same posts
- Echo the number of posts being displayed
- Exclude a category of posts in author template
- Get author posts count after excluding a category
- Display specific posts on home page
- Have h2 tag not show up if there are no blog posts
- Order posts by date
- MySQL: Possible to replace all of wp_posts.post_content(id#) via UPDATE + REPLACE + SELECT?
- Deleting post tags removes categories
- Move position in post list for a custom checkbox column
- How to put the author of the post in the comments?
- Check if almost 10 year old – working code is up to date
- MYSQL: Create SQL query to search for string and replace
- How to add a custom class attribute into code wrapper? [duplicate]
- Bulk find & replace on WordPress posts/pages (minus image paths)
- query posts with selected post ids first
- Remove pagination if search returns empty
- Remove HTML tags from all posts
- Save All Post Permalink From A Specific Category into a .txt file
- How to Display Most View Post in the template file?
- wp_query args with relation
- Show post excerpt
- Post that populates itself (almost) automatically using data from imported excel file
- How do I apply a wordpress function to something with no ID inside an archive page?
- Show author bio box
- Use special template for the first post in the loop
- Allow reader to reorder posts for themselves (oldest first)
- Repeating post how to solve this
- show latest authors blog post
- Call image from post on index page?
- How to get only current images of a post
- How do I get thumbnails?
- Run function after post is updated
- FIND and REPLACE wp_posts AND IGNORE custom post type mysql query
- wp_query select if have comments
- Getting rid of the blog page entirely
- Creating pages and getting their values from the database table
- Last three posts not being put in order by date. How to fix this?
- Notify Author of the post if admin deletes his post and perform some function
- Sort Posts Alphabetically Based on Specific Category (Divi)
- How to change url of posts?