The simplest solution:
echo get_the_category_list( ', ' );
Following your way:
Change your $args
like so:
$args = array(
'template' => '%2$l',
'term_template' => '%2$s',
);
And then, add this to your functions.php
file (this will affect all %l
markers!);
add_filter( 'wp_sprintf_l', function($templates) {
// $templates['between_last_two'] = sprintf( __('%s, and %s'), '', '' );
// $templates['between_only_two'] = sprintf( __('%s and %s'), '', '' );
$templates['between_last_two'] = sprintf( '%s, %s', '', '' );
$templates['between_only_two'] = sprintf( '%s, %s', '', '' );
return $templates;
});
Related Posts:
- Display only deepest category on a single post?
- Taxonomy name repeating when showing 2 posts from each category
- How can I improve this taxonomy treating approach?
- Custom taxonomy template for categories
- How to insert category list into post creation page, and retrieve chosen categories?
- What Must to Display the “mysite.com/category” URL?
- How to get posts using category slug in ClassiPress?
- Category post count is not correct
- Include last post date in get_categories loop
- Order Categories by Character Count
- How can I display the number of post associated to a category in Twig/Timber WordPress? [closed]
- Display sibling categories on category page
- How to modify the output of wp_terms_checklist when used within the built-in category metabox on edit posts?
- How to loop custom post_type from (a) specific category(ies)?
- Do not show sub categories in the loop on archive-product.php
- WP REST API not retrieving all categories
- How to display a value inside a post with a specified category from a category custom field? [closed]
- Some categories missing on wp-admin/edit-tags.php?taxonomy=category
- Is it possible to have a template that works on multiple categories where the link address contains the specific category?
- Echo text using is_tag
- List just subcategory and products of active category page in Woocommerce
- How to display the parent category if only the child category has been chosen
- Category tags with comma’s
- Display posts of certain categories to specific user roles
- Custom template for sub-sub-categories
- Allow user to select categories that will display in post loop
- Grandchild Term Things Grandfather Term is It’s Parent
- Insert HTML content in WP Query at specific point
- Eliminate word from $term->name
- Simple way to style posts of a single category differently in the loop and in single
- WP 4.7 in_category change?
- Remove any product that is featured from regular display loop [WooCommerce]
- Two Sections on Woocommerce Catergory Page [closed]
- Get posts of a custom post type from category from taxonomy?
- Getting the Most Recent Posts from Multiple Categories
- How to use wp_list_categories with plugin category?
- Using if statement in index.php instead of creating separate template files
- Display subcategories in dropdown
- Illegal string offset ‘taxonomy’ in
- Style a category from category list
- Why is my sub-category template showing the wrong posts
- Display category title and three latest post inside the category
- More efficient way to list posts by category [duplicate]
- Same menu for different taxonomies to reach different content
- Change categories count to include media attachments
- How to schedule categories?
- Template for product-category page [closed]
- Add Date & Author Meta to Category Archive Page
- How to get selected taxonomy or category ID if using custom walker?
- Have posts that belong to multiple categories, exclude some categories from homepage
- Category nicename inside loop in wordpress
- Display subcategories selectbox on each category page
- Show multiple categories in query using redux framework variable
- Get the ID of the current post’s child category
- filter a loop base on specific category
- Problem with multiple loops in wordpress theme
- Let user select their own category
- Displaying year once in category.php [duplicate]
- multiple values in an array for category__and does not work with WP_Query
- Copy post taxonomy?
- Category link redirect to custom template page instead of index.php?
- I would like to feature a tip on the homepage
- How could I write a get_categories_by_year() function?
- Get posts in a subcategory of a chosen parent
- Limit Loop to One Category
- Display post thumbnail for specific category outside the loop
- List post only under the category, exclude child category content
- How to differentiate the homepage structure from the category page structure in WordPress template?
- Filter Category Loop Dynamically
- Setting selected term_id with wp_dropdown_categories?
- creating categories programmatically
- Natural sort / ordering wp_dropdown_categories
- Editing Loop So It Targets Specific Tags?
- How can I include custom category and tag base in template files?
- the_category() doesn’t working in wp_query loop
- Conditional category query breaking?
- Problem: retrieving parent category’s first post
- Different header for each category
- Category Template – Show Last Entry as Featured
- Custom post type archive category page results in 404
- Best way to categorize/populate a magazine style layout
- Category sticky latest
- Include home page template in specific category template
- Combining these queries? (Same taxonomy term + same category as post)
- Posts made to category don’t show up (do show up on frontpage)
- sidebar troubles, taxonomy trouble
- Output Title of Post’s Current Category
- Exclude posts without category from loop
- Showing different posts on category pages
- Displaying categories in different template problem
- Displaying posts of given category
- Display ACF category image on archive and single template files
- get_the_category – display only a single category for a post (not all categories)
- display category with background color
- Category name for all posts getting assigned to a single random post
- Display all categories but only if they have posts in them that have a specific tag assigned
- Disable Category Taxonomy
- WordPress Default Category and Custom Taxonomy Selected Attribute not Working After Searched in wp_dropdown_categories Array
- Show the number of the post
- Automatically adding tags and categories into Post Excerpt for searching