get_categories()
uses get_terms()
so the array argument you can pass it will be the same.
From the documentation the array can have a property hide_empty
, by default its true
.
I’m guessing that those categories have no posts attached to it, if that is the case you will need to set it to false
.
The code would be like this.
get_categories([
'child_of' => 505,
'hide_empty' => false
]);
Update
If you want to order the results you can add order
to the array, the default value is ASC
so you will need to set it to DESC
.
get_categories([
'child_of' => 505,
'hide_empty' => false,
'order' => 'DESC'
]);
You can check WP_Term_Query::__construct( string|array $query = ” ) for all the available arguments you can use.
Related Posts:
- Could not insert term into the database
- Activate Gutenberg in category-descriptions
- How to show subcategories in categories else show posts
- How can I get category ID by category name?
- How would I increase the Author Role to be able to add a new category?
- How to remove the parentheses from the category widget
- Randomise results from a category page?
- Adding Custom User Profile data based upon Categories
- Only show category to certain user levels without plugin
- How to: 301 Redirect /category/ to /customname/
- Custom Query to search through categories
- Order posts by category name
- How can I make wp_list_categories output li with category-slug as class, for its children?
- Get sticky post from category?
- Display one latest post from multiple categories
- Remove word “Category” from WooCommerce product page [closed]
- Remove Archive Headline and Archive Intro Text fields on category and tag archive pages in WordPress Admin with Genesis framework
- Output link to category from WP_Query loop of woocommerce products
- How Do I Merge Categories With phpMyAdmin
- Display name of the last child category
- Edit the markup of categories list
- Show category children, one level
- If in category to be inside of a function
- How to exclude posts from a category when using this particular format
- Viewing category pages without the word ‘category’ in URL
- Different excerpt styles per category, but chronological
- Show only one category
- Pagination Not Working on Category.php page
- How to view WordPress’ default category IDs?
- Random taxonomy category list
- Broken category pagination
- how to change template?
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Product Category WooCommerce
- Show all posts for a specific category/author
- Hard coded main navigation
- Resort get_categories
- one category template for multiple categories
- Display posts separated by Category in Author’s page
- How can I define a custom archive for childs of a specific category?
- Category shows only top level child categories
- The arrangement of categories always change while posting article
- Woocommerce custom category page with pagination [closed]
- REST API: Display Category names in JSON?
- List posts in alphabetical order
- Where is the category of a post stored?
- Categories list loop – add separator every 3 categories [closed]
- wp_list_pages() exclude category
- Limit categories and it’s subcategories for specific group of users
- How to define multi categories posts number
- Get the ID of 10 Latest Pages stored in a WordPress Category
- Admin: Navigation Menus do not show empty categories/taxonomies in the list’s search tab
- getting post data in functions.php
- Category specific order
- how to separate categories in loop.php?
- How can i remove the posts category class names from body_class
- Different Category Headers using in_category and elseif
- Remove the number of posts displayed in wp_list_categories()
- WP_safe_redirect not working
- related articles using shortcodes
- “Virtual category page” based on a custom field filter
- Show category meta in loop on homepage
- How to get selected taxonomy or category ID if using custom walker?
- How to hide widget from certain category
- Category link redirect to custom template page instead of index.php?
- Rebuilding a Site: How to Show Several Category Posts in Woo Framework Theme?
- Get categories related to particular category
- the_category() doesn’t working in wp_query loop
- Displaying links to all posts of the same category on the post page
- handling the featured category
- Add class to current post in query_post
- separate posts to have (kind of) 2 blogs?
- create relationship between posts from one category and posts from another category
- Exclude the category of the current post
- Sort posts by child category name
- Intermittent Gutenberg 504 Gateway Timeout when calling REST route to retrieve categories
- display specific category when website loads
- Excluding current category from sidebar’s post widget, elementor, query-id
- OK to redirect the root WordPress category slug?
- Show subChild categories
- Inline If statement to echo CSS [closed]
- Template category.php with page (no posts)
- How to show WooCommerce Categories on ‘shop’ page instead of products?
- How to create Child Category page from scratch at wordpress?
- How to insert category to post via php?
- How to set featured image as background for a specific category?
- Show Subcategory Name Instead of Parent Category
- Get category id of next / prev post inside the_post_navigation
- Limit Category/Tag Dropdown To blog_id in Multisite Install With Global Categories/Tags
- Adding relevant categories to related post
- Code to display category-specific single.php is overriding normal single.php, too
- How can I add a Categories page link to a menu? [closed]
- Media Library filter returns undefined function get_current_screen
- Custom built theme won’t filter categories
- Way to show content of a post, but if exceeds character limit revert to excerpt?
- get IDs from links categories
- Display all subcategories for a product category in woocommerce
- Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce
- Why does my WordPress index has a category?
- how do I exclude a category foreach
- CPT Custom post type Tags & Categories not showing for ‘Editor’ user in editor