Your question it make sense to me my friend but the get_categories don’t have the option to order by “meta_value_num” and then order by custom fields.
What you can do is order after you get the array using the usort php function:
$all_subcategories = array('parent' => $categoryID);
$categories = get_categories( $all_subcategories );
function order_categories($a, $b) {
if ($a->term_id == $b->term_id) {
return 0;
}
return ($a->term_id < $b->term_id) ? -1 : 1;
}
usort($categories, "order_categories");
It work fine for me. I used ACF to add the category order field but is fine the way you made it and should work.
Related Posts:
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Max length of meta_value
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- How can I display all values of a custom field from posts with a certain value of another custom field or from certain post types?
- get_pages sort alphabetically by meta value
- Assign/update the custom field value for all posts
- Order by custom field date with ASC order
- How to break meta values into different items and avoid duplicates?
- WP_query : meta_key with custom rule for specific value
- Escaping Quotes
- trim custom field text value and show (…)
- Query post order by post and desc not working
- How to wrap meta values seperated by comma in ? [closed]
- How to create a Custom Meta Box with Name/Value Admin User Input Fields?
- Run a check for multiple meta key values
- Filter by custom field (meta_key) using JSON API
- How to select posts from multiple categories and metavalues?
- Removing link ” from ” on meta_value in custom feilds
- How to get categories with posts by custom field value?
- Sort alphabetically by custom field
- Trying to sort and display categories(not posts) by custom field: ‘order’
- pre_get_posts : only get posts by wp_usermeta value
- Get categories query not working in function.php
- meta_value and meta_key filtering returning no posts [closed]
- IF Custom field value equals ZERO
- List custom field values in alphabetical order without repetition
- How to update a custom field in all posts with the value of another custom field in the same post?
- Update post meta custom field using block editor
- How to add custom filed value after in wp post title
- Sortable Custom Columns not sorting correct
- query_posts with meta_value
- Show array of meta_value in Edit Post Coloum
- Making WP_Query limit results by date before today where date is a meta_query
- User query – getting values for custom meta keys/fields
- get posts based on non-single metadata
- Set class if a meta value is set within post archive
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Create Shortcode shows only posts with custom_field meta
- 4 Unique Random Posts based on Custom Field Values
- Custom Field: Display only if a specific key is selected outside the loop
- WP Query Args – search by meta_key or title
- Saving multiple custom meta box fields
- get Custom field label (select/dropdown) on front end
- Can I count every article following extracted meta value?
- Best Practice for storing aggregate data by date or other criteria?
- Block Editor – Meta values not saved, meta changes to empty array on update
- Can I exclude a post by meta key using pre_get_posts function?
- How to hide meta box values from custom fields list?
- Added 20 Custom Fields. Only 10 showing in drop down
- How do I order by multiple custom fields using wp_query?
- How to add dynamically the main parent pages’s custom fields and their values to all sub-pages?
- Front-end update_post_meta with ajax
- Why does this Quick Edit checkbox save the value only when unchecked?
- Show posts on a Google Map
- Change the RSS Publication Date to use a value from a custom field
- Filter out posts before display category count
- Compare WP Custom Field date
- Count how many posts have a custom field set
- using multiple meta_key and meta_value in query_posts
- Multiple relationships in a query
- How Meta Data is different from Custom Fields of POST/PAGE in WordPress
- global function to apply filter to custom field
- How to add a new meta key and assign timestamp to posts
- Print custom field in Query Loop block
- Is there a simpler version of WP Media?
- Order RSS content by an advanced custom field value
- Advanced search by two criteria – sort by location and date (ascending or descending)
- Collect user custom field in product page woocommerce
- Outputing a metabox textarea and avoid line breaks inside li tags
- Restrict WordPress Search to Custom Field
- How to add a custom field to a post created programmatically?
- How to mass update custom fields for more than 20k posts
- Problem with saving large amount of data in postmeta/usermeta
- How to get posts with a metadata numeric key greater than X?
- List all unique custom field values?
- “Matching” or “Linking” Two WordPress Pages: Custom Fields?
- Build index page from custom fields
- Meta_query ‘compare’ => ‘LIKE’ not working?
- Modify date query by URL parameter using pre_get_posts and $_GET
- Get text from user and display it on page
- Upload & include specific JavaScript files for posts?
- Custom meta boxes not saving
- help for user login
- How to delete file uploaded by Plupload
- Display Meta Data with HTML?
- How to store meta field values
- Order by custom date field
- Group Posts By Custom Meta Value: Date
- Custom Field: how to save array of multiple key-values in WordPress
- How can I detect user’s timezone?
- ACF field group not showing in page
- Custom field in media library not saving, selected() function not adding “selected” to select list input type
- Is there a way to save different data when USER interacts with the same POST?
- Showing the post only when there is title, thumbnail and the content in Custom Fields
- Show Custom Taxonomy as Headline for related posts
- Custom field group on page
- display Flexible Fields from options
- change attachment custom field onChange event
- How to filter post using custom feild value in shortest and longest duration?
- Advenced custom fields auto fill problem