I am not sure if querying the categories again is the good idea. The following code extends the Walker_Category
and makes use of it to do the replacement. Put the following in your functions.php:
class WPSE67791_Walker_Category extends Walker_Category {
public function start_el(&$output, $category, $depth, $args) {
parent::start_el( $output, $category, $depth, $args );
$find = 'cat-item-' . $category->term_id . '"';
$replace="category-" . $category->slug . '"';
$output = str_replace( $find, $replace, $output );
}
}
Then call wp_list_categories as following:
wp_list_categories(
array(
'child_of' => 4,
'walker' => new WPSE67791_Walker_Category
)
);
Related Posts:
- Get the children of the parent category
- Check if a post is in any child category of a parent category
- How to make child categories recognize parent’s template displays
- Show children of top level category only
- Show only first children level of current category?
- Query Posts Exclude Entire Category
- Category shows only top level child categories
- How can i remove the posts category class names from body_class
- Give Children Unique ID’s
- Get categories list with category name in custom WP_List_Table class
- How to get category names in post_class?
- Check is category parent with ids from the childs – get_term_children
- post_class remove tag- or category- from slug
- Check for parent category
- How to create template for children category?
- Need list of child category post titles sorted by child category
- Different styles for categories – need to edit a plugin
- Children categories not shown in dashboard
- list first post of Child Category on Category page
- how to display page title only for child category pages
- How to retrieve posts from parent category, splitting them per children when displayed?
- Is There a Difference Between Taxonomies and Categories?
- Only one category per post
- Get rid of WordPress category, tag and author archives?
- Filtering categories in the permalink structure
- get_categories hierarchical order like wp_list_categories – with name, slug & link to edit cat
- Why aren’t sub-categories nested after creating post in the WP Admin?
- Preventing index.php?category_name=something from redirecting
- How to get category id of current post?
- Programmatically create product category and add thumbnail in woocommerce
- Trash bin for categories
- Categories’ hierarchy in URL
- How to get next previous category in same taxonomy?
- How to add a background image to category and display image on category page
- If a post has two categories with different permissions, what will happen? [closed]
- Filter out posts before display category count
- How to show in search results posts with a particular tag in a particular category?
- Category vs Tag vs Table
- Multiple menu items highlighted
- Categories not working – 404 Not found error
- wordpress wp_list_categories
- Group listed elements by category
- Highlight wp_nav_menu when category is selected
- Get link which associated with a specific category and tag
- How to disable default category linkbuilding?
- How to assign posts without any category to the default category
- Show only first category name in RSS?
- Show parent category in URL of subcategory archive page
- Yearly Archive for Categories with dropdown
- get_categories listing foreach with children
- Removing subcategories from permalinks [duplicate]
- Different banner for different section
- How to query categories with Advanced Custom Fields?
- Undefined property: stdClass::$id when retriving term ID
- Wacky taxonomy in wordpress
- Link to the next/prev posts in index loop in same category?
- Output the text before category
- Change div background acording to the selected category
- get_the_categories() but exclude children of “Uncategorized”
- How to exclude a particular category from the category list
- Why title_li =” not working
- Custom Permalink with child categories creating 404
- Show all sub categories?
- Category nicename inside loop in wordpress
- Exclude all subcategories in the_category (post)
- Displaying another main nav menu for specific category
- Exclude categories from list (wp_list_categories)
- WordPress: Using the category slug get the category ID using mysql query
- Create a Category with a front-end post
- Exclude category to “the_breadcrumb” functions
- Global navigation in multisite: problem with categories
- Migrate the posts of a category to another blog as a custom taxonomy
- Woocommerce only display child category when parent is checked (on add new product page)
- Add $args to wp_list_categories
- How to hide a category or tag everywhere EXCEPT for use with get_posts
- Show parent category wp_list_categories wordpress
- Taxonomy custom check box meta field not getting saved
- Subcategories randomly not working after page/post/category edit in wordpress. Fix: saving permalinks twice
- In if…else condition, the else statement shows even if if statement is correct
- Restrict retrieved terms by category?
- Get category from slug list
- I just want to list ONLY the child categories, but not grandchildren
- How to Change Sort Order of default WordPress Catgory Widgets?
- Custom filters inside a specific category?
- $args Orderby The number
- Most efficient way to have 1 template for parent, 1 template for child categories?
- Function to list posts from current post’s category fails in WP 3.8
- Multiple parent categories
- Custom fields setup when category selected filter subcategories
- Make three menus with three category levels
- how to call the category of the post
- Category related -> excerpt, title and thumb in sidebar on article page
- How to have a category not show up in query post with page panigation?
- single category widget with conditional terms
- Remove the current item from a menu
- why is the delete option missing from just one category?
- Get all categories
- Show category post order ASC
- How to display all category images for single post in a page?
- Restricted category in Woocommerce [closed]