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
- WordPress Post Query Using Custom native MySQL like St_Distance_Sphere
- How to display the link (title) and thumbnail post?
- Sort WP posts by span value
- Force the “Choose from the most used tags” meta box section to always be expanded
- Show the content that is after the excerpt using child theme
- How to allow users to post only in certain category and hide elements from edit page?
- How to do set post permalinks using 6 digit random unique function?
- Can’t get buddypress notifications in front-end; why do I get this error?
- How to sort posts inside categories
- Get user categories with most posts in it
- How do I display some posts fully on the homepage, and some as an excerpt only?
- Random ajax load only works with posts_per_page set to -1
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- MySql query to get posts with all meta and terms
- Send post id through ajax and get the post content back
- Display an author’s posts on his own author page
- Any way for get_next_post() to use the actual post order instead of publish order?
- Multi row post list
- Display post x of y within category
- Force authors to Preview a post before publishing
- WordPress Automatic Filename Changer
- posts_per_page option limits the number of Gallery items
- List authors with the last post title and order by last post date
- How to order posts by meta_value and title
- How to make multiple sections in home pulling posts category wise?
- wp_posts table: safely remove unused columns to save database storage
- Query Posts by Custom Field
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- Remove a shortcode from all WordPress posts
- How to order posts in an arbitrary order?
- What do these phpMyAdmin errors mean on my WordPress databaes?
- how to get post order by post id wp_query?
- Display Posts on Custom Page
- How to get posts from a current post’s month?
- How Do I Get My Post Tags to Alphabetize?
- Wrong post title displayed from loop
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- do more action after I publish a post
- Retrieve only posts from a specific user in wp-admin/edit.php
- Conditionals if tags exist?
- Delete post results in “Cannot delete or update a parent row: a foreign key constraint fails”
- Change all author links in Blog roll
- WordPress website loads more posts than expected
- disable Tab post on nav-menus page (Admin)
- Get the amount of posts on a current page
- Adding bootstrap classes to video shortcodes
- Posts – display all posts except a post by an ID
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- Counter is skipping post when I still want it visible [closed]
- Every second post different class in blog view
- Format latest/newest post differently
- is_page Funtion for Posts ?
- query post limits
- Make a vertical dynamic list of posts in alphabetically order and in columns [closed]
- Create a list of posts with topic headdings
- Post type no single page
- update image path with words starting uppercase to lowercase chars
- why the same code got different results when using query_posts in functions.php and index.php
- Display Posts with template on a Page
- Get post meta retrieving wrong value
- Query for first 3 posts to change the look and feel
- Adding a user’s ID behind the tag ref link address
- Archive template combined with post slider and regular posts
- How to get posts published on the latest date?
- The_excerpt() doesn’t parse – how to change that?
- How can I add a box to edit Order on a regular post?
- Isn’t the way posts are displayed very unefficient?
- Add custom text automatically on each post
- Shortcode with ‘year’ parameter
- Post Filtering by GET URL parameters
- On what hook can I get the queried object’s final state?
- restrict incrementation of post vies count when refreshing the page
- Defined function isn’t showed on page
- wp_query with ajax
- How to give classname to post if post has no content?
- WordPress 302 Redirect to Random Product/Post/Page
- How to use mysql LIKE with wpdb?
- Get the most recently modified post date of most recently modified post
- Queries take 120+ seconds on my large WordPress site
- WP_Query: Show 10 posts in date order, first three random
- Custom posts listing widget always returns 1 extra result
- Database hacked – random posts are modified
- Getting Whitescreen when publishing a post [closed]