This part of code from the question will fetch only parent category because 'parent' => 0
, drop this from array if you need all the categories
$categories = get_categories( array(
'orderby' => 'name',
'parent' => 0
) );
// You can iterate over the list of objects returned by `get_categories`
// to achieve list of categories in required format.
$category_list = array();
foreach( $categories as $category ) {
$category_list[$category->slug] = esc_html__( $category->name, 'kirki' );
}
Related Posts:
- Is There a Difference Between Taxonomies and Categories?
- What is the difference between a “tag” and a “category”?
- Control term order on a per-post basis
- get all tags from category
- 404 Error On Category and Tags Pages
- Checklist of selected categories
- Rewrite URL with category and tag combined using WP_Rewrite
- How to tax query X number of posts related by tag first, then by category if not enough in tag-related
- Category and tag with same name
- In the tag archive – display count of posts for each category they belong to
- Automated adding of one tag to all the posts in a category
- View category in the preview of Theme Customizer
- Moving Categories submenu to Media, but still opens Posts menu
- Return array of categories to php function
- Exclude most recent posts from specific category in wp_query()
- When using get_categories or similar, is it possible to filter results that contain certain Tags as well?
- Listing all posts from current category on page
- Display WooCommerce product categories in a 4 columns custom menu [closed]
- Deleting All tags except categories Wp database
- Search by word, category, tag, author
- How to filter archives both by category and tag?
- Get tags specific category
- Dropdown category filter
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- Category vs Tag vs Table
- Help with multiple dropdown tags search
- Custom WP_Query for current category (in category.php)?
- Retrieve all posts within tag OR category?
- How to find the number of Tags a post has?
- How to not treat categories as tags in feeds
- How to customize tag and category post listings to show introductory content?
- Are Category or Tag Archive Pages Possible?
- Random post + categories + tags
- Search Posts / Pages with multiple options?
- How get permalink for the current category or tag?
- Display tags from specific category in select fields
- Offline WordPress Application
- Find out which user created a category or tag?
- RSS/XML of all Categories and/or Tags
- Get Tags specific to Category using WooCommerce plugin
- How to make 2 tag feeds show up on 1 page?
- Different templates for different category tags
- Site search needs to find posts for category topic AND Tag or keyword thats not in the post
- Get link which associated with a specific category and tag
- How to get related tags based on a category?
- Needing a snippet for listing category specific tags
- How to list categories within tags?
- Use Tag input metabox style for Categories
- menu using category and tags
- limit a list of tags to one category [closed]
- How to use an array of categories as a dropdown?
- Have multiple category queries from the URL been fixed yet?
- Create menu locations for each category in wordpress
- Is there a reason I cannot get the current category in a loop?
- Use premade array as categories in wp_query?
- Array: What is this value based on?
- Display all product tags associated with a specific product category
- How replace individual elements in the RSS feed with a single string
- Adding a H1 Tag to Post Tags automatically, but hide the tag? (Same for Category)
- Getting Category Children
- Tags Instead of Category
- Conditional category & tag statement
- I need to exclude from a query a category and a few custom taxonomies
- Include either name or slug in the include parameter using wp_list_categories?
- How can I filter posts by tag on the fly
- Filter categories/tags to display in multiple metaboxes for selection in back-end
- Editing Loop So It Targets Specific Tags?
- How can I include custom category and tag base in template files?
- Pretty URLs with Categories and Tags
- Autolinking keywords in text with tags
- Maintaining a separate posts page for certain categories and don’t show those on home page
- Are tags different than categories?
- Custom menu with categories and tags
- Show Posts via cat+cat in URL that are in both Categories doesn’t work
- Display all categories but only if they have posts in them that have a specific tag assigned
- Help to display the current categories and tags of a post
- Hide specific category tag on single post page
- Filtering posts in category by tag URL
- echo $category[0]-> cat_name; shows only one category name
- How to show entries related to main category
- When creating category, it creates automatically tag, or, when creating tag, it creates automatically category in same name
- Using heirarchial tags or Custom taxonomies
- Re-coding category-template.php to go to custom URL
- Category and tag urls return 404 error
- Cant get unique_array() work on get_the_category() foreach loop
- How to echo Tags and Categories as plain text
- Tag Menu items based on their categories
- Hide category name using mod_rewrite
- How to exclude category and post_tag taxonomy while displaying custom taxonomy?
- 404 error when i try to search by category or by tag
- A simple question regarding tags and categories
- Display related posts with same category or same tag return blank
- htaccess redirect for all categories converted to tags now showing 404
- Loops in category description
- How to create a category or tag available exclusively to the admins and not to the users?
- altering theme – content generated by PAGES not PORTFOLIO
- Search tag within category
- Matching usermeta at registration to categories of content
- List products from current category
- How to define category ID in an array?