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
- Stop WordPress automatically adding tags to post content
- Let private posts stay in status “private” after edit through “editors”
- how to get a different html for odd/even posts?
- How to display posts by current user/author in a custom page template?
- Display most recent post in category instead of archive?
- Human Time Diff, change mins to minutes
- Display the latest posts, published in the last hour, with WP_Query
- same template for multiple custom post type single
- Allowing the SoundCloud player to appear in a post excerpt
- Converting multiple loops into one single loop with pagination
- Run a function when post is deleted?
- Exclude posts w/ specific post_meta on Rest API endpoint
- How to change wordpress dates to native language (even if the languge not available i wordpress)
- WP_Query orderby not working with meta_value_num and menu_order
- Bulk delete WordPress posts with phpMyAdmin
- Show post content and title in diferent divs using WP_Query using a loop
- Check if a custom post type has already been created
- Reinstall WordPress while keeping attachments
- Custom WP_Query not working correctly
- Echo the number of posts being displayed
- Get post related to particular meta box? [closed]
- Exclude a category of posts in author template
- Open post within Foundation 3 Reveal
- Format array of objects to json for wp-json
- MYSQL: Create SQL query to search for string and replace
- how to filter posts by category without page load (ajax) in wordpress?
- How to add multiple(but specific) posts to different areas in one page?
- Custom Post Type doesn’t use single.php or single-{custom_post_type}.php
- Display all posts/pages in a multiple selectbox
- How to only allow post to be deleted if custom field doesn’t exist
- How to set a link to custom archieve page
- Moving Posts to a new site and maintaining URLs
- Changing permalink of custom category
- Special Query: Title, Terms, Content – %LIKE%
- How to limit the number of posts a user can publish based on user type
- Add News Feed to bespoke website, only to one page on whole site
- WordPress Custom Post type csv exporter