Use the orderby
and order
parameters in the argument list. See the Orderby_Parameters section of WP_Query for details.
$category_ids = $arr_records = $post_data = array();
$categories = get_categories( 'child_of=4' );
foreach( $categories as $category ) {
$category_ids[] = $category->term_id;
}
$post_data = get_posts( array(
'cat' => $category_ids,
'orderby' => 'title',
'order' => 'ASC',
) );
$post_data
should now be sorted by post title [A-Z].
Related Posts:
- how to get post order by post id wp_query?
- How to Change Order of Posts in Admin?
- Random sort within an already sorted query
- Different post sort order within different categories
- Setting Custom Sort Order of Posts within a Category
- Can I force a metabox to be in one column?
- How to Group Posts by the First Letter or Number?
- How to Arrange Posts by Size in the WordPress Dashboard?
- How to query serialized array by comparing greater than (>=)?
- blog posts sorting doesnt work while using get_query_var
- How to sort posts by last name (2nd word) on ONE category only?
- Group Posts by First Letter of Title
- JSON not valid after json_encode posts
- how to limit and display tag?
- Sort wp post title with alphabetically and numerically?
- Exclude posts with specific meta_value while sorting by a separate meta_value
- Possible to create a permalink to sort with meta_key?
- How to choose a sort order (for posts) per category? (ideally when creating a new category)
- Plugin for sortable posts in grid [closed]
- How to update serialized post meta?
- How to display sorted posts in the ‘All Posts’ page
- Sort posts by newest child while keeping hierarchy intact
- Filter Posts by Excluding Categories
- Sorting posts alphabetical that have single digits
- Sorting posts according to the term they belong to
- Sorting posts according to view counts not working
- Server-side sorting of posts
- Insert woocommerce products programmatically with featured image and gallery
- Add multiple tags to multiple posts
- How to sort posts inside categories
- How to display posts via custom taxonomy terms using checkboxes?
- Custom order for Mysql array
- how can i change WP main archives loop to sort by name or title
- Sort Custom Post Type by Category ID then Post Name
- Post filtering is returning blank page
- Sort by last word in title
- Querying another post category to match current post and display in loop
- Get latest post from categories
- Sort All Posts by Category Name in the Admin Panel?
- How to list post as buch of category, and all of them
- Categories Listing and Highlighting current category item
- Save / Update meta data as multidimensional array
- Merge get_comments & get_posts into a single query
- How to sort WP_Post Object array by object field in php?
- Sorting post by custom field and category
- Ajaxify Post Sort
- WordPress text field in array problem
- How to sort posts in admin by name
- Get the correct meta_value with get_post_meta
- I am not getting result from php function that is json encoded
- Sort / Filter Queries
- Get current user array with post string
- Sorting Posts by Date – get_blogs_of_user_id()
- How to get alphabetic listing x other posts, based on first letter post?
- Why is $_POST Empty in Profile Edit Admin?
- Sort by category and then date?
- Exclude a ‘portfolio’ custom category?
- custom sort posts in archive/taxanomy page
- posts_per_page – Repeats only first posts ‘post__in’ array
- How to create a cumulative posts and members count
- Filter/Sort Post Form On Taxonomy page
- Sort Posts Alphabetically Based on Specific Category (Divi)
- How to sort posts alphabetically based on a specific parent category
- How can I change the post order after filtering in WordPress?
- Parameter for pagination posts_pagination
- Detect if the currently opened document is a post
- More Than 50K Categories and WordPress Admin Panel Stop Showing Categories and Posts
- Hiding the name of the user who is currently editing
- Loop through taxonomies and loop through their terms (Newbie question)
- Spam written by registred users
- Get posts from category from custom query
- allow editor/author to publish others posts but not publish their own
- Count posts for pagination
- Changing a users posts to drafts upon role change
- Why does media_handle_sideload upload to last month’s folder?
- Re-order Category Meta-data
- Slug collision between page, taxonomy and custom post type
- Populate a drop down list with post titles across a multisite network
- Show 5 posts and than 3 posts offset with pagination
- Sorting Posts by Taxonomy thats not within the query’s $args
- If taxonomy has more than 6 posts, display show all
- My posts page is missing the page title
- Hiding title of selected post without plugins
- What’s the best approach to create duplicated pages with paginated posts?
- Very weird behaviour after removing WP pages
- Blog Post slider not working
- Double loop output
- AJAX load more posts not using correct category and repeating the same few posts
- I need some explanation on global $post [duplicate]
- Custom permalink for wordpress page / post
- How to Display Most View Post in the template file?
- Multiple Pages – Seperate blogs
- display multiple posts and posts content on a single URL
- Order result from ajax
- Show post published live
- how i show manual data in a post
- New blog post published notification – Buddypress
- Change archive results based on GET request
- Custom post styling per category?
- Let Contributors Review only (Not Publish) Others Posts