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
- How to get posts published between a date and today?
- How to detect single.php (but not single-portfolio.php)?
- How to Change Order of Posts in Admin?
- MySQL Query to Retrieve Category from wp_posts
- disable WP automatically inserted line breaks after an image
- Sort posts by popularity/page views
- delete post also attachments
- How to sort posts by last name (2nd word) on ONE category only?
- Manually delete post from database
- Restrict users from editing post based on the age of the post
- Query posts distinct authors
- How to get previous 10 days post from a specific date – WP Query
- Can’t show comments count per post outside loop
- How to display post tags
- Allow role to delete posts but block him the wp-admin
- WP_Query in functions.php overrides global $post object, even with wp_reset_query()
- How can I list random authors from current post category?
- Disable single post page
- Filter Posts By Tag
- greatest() function returns undefined property
- Enabling post thumbnails for custom post type
- Reset/Reorder posts ID in the MySQL wp_posts table
- Exclude newest post from category X but show rest
- Reset Popular post query?
- Prepend or add an Image to the content of a Post
- Why orderby=”date” does not support manually changed posts?
- Display posts with tag that matches current post title
- wp_insert_post – duration
- How to display the link (title) and thumbnail post?
- Any way for get_next_post() to use the actual post order instead of publish order?
- wp_posts table: safely remove unused columns to save database storage
- how to get post order by post id wp_query?
- Display Posts on Custom Page
- disable Tab post on nav-menus page (Admin)
- Adding bootstrap classes to video shortcodes
- Counter is skipping post when I still want it visible [closed]
- Every second post different class in blog view
- Make a vertical dynamic list of posts in alphabetically order and in columns [closed]
- Get post meta retrieving wrong value
- The_excerpt() doesn’t parse – how to change that?
- Add custom text automatically on each post
- wp_query with ajax
- How to give classname to post if post has no content?
- Custom posts listing widget always returns 1 extra result
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- Restore woocommerce orders
- Get postlist for each category using query_posts?
- How to save posts position on homepage after random function?
- Posts and order
- Adjust the order for returned posts
- Help on conditional statement to accompany wp_insert_post function please?
- Pull in posts using post meta for REST API
- how to show comments only author which send own posts in wordpress
- Alt text attributes not showing over portfolio images
- How to show post views shortcode data for each post on Posts List Page?
- Set a post expiration and delete a post when expirate
- Replace Tag Keyword With Link Within Post Content
- How do I display posts ordered by a date custom field?
- Get post id outside loop : Notice: Trying to get property of non-object
- WP_Query to get posts in a specific tag or has post_format
- Make recent post display recent updated, instead of recent published
- Manipulate query to show specific post
- Random order of the 5 most popular posts
- My custom query is displaying random posts in random order
- Get query result according to merged array
- How to change number of posts shown on homepage vs other pages?
- Sort / Filter Queries
- get_page_by_title() not working if special characters are present
- Show only top 3 posts from 3 categories in order on home page
- get “read more” with custom DB query like you would with WP Query
- SQL query to remove first image in all posts
- Get post title by Alphabet
- How can I create a menu items from meta box based on users input
- How to use wp_editor(); in functions.php then retrieve content in the template
- save_post not working
- Change from all posts to specific categories post on main page?
- Custom Post-Rename Function Does Not Function in WordPress 6.x
- Count words for all posts by all authors
- Do I need to create a multisite for querying posts from multiple WordPress sites?
- Show Next/Previous without Link
- Dynamic archive of posts by date
- Filters do not work when there are multiple (one works)
- WordPress current post functions inside loop doesn’t work anymore, are they incompatible with php 8.0?
- How can I strip a single tag from an email post