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
- get_categories for custom post type with a specific custom taxonomy attached
- Could not insert term into the database
- Exclude the category from the WordPress loop
- Weird behaviour when adding terms/term_taxonomies programmatically
- get_field not displaying my custom field value
- Randomise results from a category page?
- Show div only if post is in specific category
- How to show a category post to a specific registered user
- Create single.php for specific category by category id
- Display one latest post from multiple categories
- How do I get the total number of categories in a list of search results?
- Display products for a category, sorted by post_excerpt
- What’s the difference between “parent” and “category_parent” in a WP_Term object?
- Display name of the last child category
- a-z list, categories and sub categories in loop
- Exclude category from Tag Template
- How to view WordPress’ default category IDs?
- Random taxonomy category list
- Need Category RSS Feed that shows all posts
- How to loop only categories without posts (+ show category featured image with acf) [closed]
- Additional featured post on first page
- Show all posts for a specific category/author
- create a page which displays a list of categories title+ short description?
- Query Posts Exclude Entire Category
- Show Available Taxonomy List with Current Category
- one category template for multiple categories
- Exclude a category from the_category in the single post page
- Why does the argument list_only do on Walker_Category_Checklist::start_el?
- Updating category template to change how subcategories display
- How can I get categories IDs if multiple categories requested via URI?
- Drop posts from categories in MySql
- Category template to show different categories based on parent
- Customize category page for different custom taxonomies
- Categories list loop – add separator every 3 categories [closed]
- Display custom taxonomy attached to the post on post single page
- Limit number of posts on a custom category template – breaking pagination
- Admin: Navigation Menus do not show empty categories/taxonomies in the list’s search tab
- Trying to get variables in hacked category dropdown
- Display sibling categories on category page
- Do not show sub categories in the loop on archive-product.php
- Echo text using is_tag
- Allow user to select categories that will display in post loop
- Insert HTML content in WP Query at specific point
- WP 4.7 in_category change?
- 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?
- Display subcategories in dropdown
- Illegal string offset ‘taxonomy’ in
- Display category title and three latest post inside the category
- Change categories count to include media attachments
- Add Date & Author Meta to Category Archive Page
- How to get selected taxonomy or category ID if using custom walker?
- Show multiple categories in query using redux framework variable
- Let user select their own category
- Category link redirect to custom template page instead of index.php?
- Limit Loop to One Category
- Filter Category Loop Dynamically
- the_category() doesn’t working in wp_query loop
- Output Title of Post’s Current Category
- Displaying posts of given category
- Category name for all posts getting assigned to a single random post
- WordPress Default Category and Custom Taxonomy Selected Attribute not Working After Searched in wp_dropdown_categories Array
- Show subChild categories
- WordPress 5.4 and higher: Filter posts by category 1 AND category 2 in API requests
- How can I order all subcategories alphabetical independent of the parent categories?
- Custom Loop with certain number of one category
- Template category.php with page (no posts)
- WordPress Portofolio Conditional Templating – functions php
- Get WooCommerce product category list in functions.php
- Confused about category.php template – not working
- Querying posts from two different categories while looping inside another loop
- How to Manage and link certain custom taxonomy?
- Loop doesn’t work
- Use different file includes for single.php
- Match two taxonomies to display a specific content
- Secondary loop cuts off at 10 posts?
- Custom Category Page Not Working [duplicate]
- Display only the latest post
- Return selected categories only in custom page meta box?
- Custom loop by url
- get IDs from links categories
- Template files not working for archives and categories
- Multiple Parent Category URLs
- Chained drop-down menu for custom taxonomy using chained.js
- Display only one level subcategory in wordpress
- IF have_posts contains posts from a certain category
- Converting Categories (with ACF fields) to custom taxonomies
- Taxonomy term RestApi data 10 rows limitions