Did you had a look at the Display Categories Assigned to a Post example in wp_list_categories
in the Codex. This should give you a very good idea on how to modify your own code. This is just my simplistic way to achieve what you want. Feel free to modify as needed
<?php
$taxonomy = 'category';
$separator=", ";
if ( !is_wp_error( $post_terms ) ) {
$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy );
$terms = rtrim( trim( str_replace( '<br />', $separator, $terms ) ), $separator );
// display post categories
echo $terms;
}
?>
Related Posts:
- List all categories in options
- How to divide and display categories into two columns
- How do I append lists in Prolog?
- Inorder Binary Tree Traversal (using Python)
- How to have a set of sets in Python?
- Learning Haskell: How to remove an item from a List in Haskell
- How to obtain a subarray in python 3
- Reversing a List in Prolog
- List Length in Prolog
- Display list of Sub-Categories and the posts they contain, within one main Category
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Categories list loop – add separator every year
- Exclude a category from the filed under list only on some templates
- Listing all posts from current category on page
- Display only one result from “get_the_category_list”
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- Editing a Post, 99% CPU?
- Similar posts formatting
- How to find the number of Tags a post has?
- Get woocommerce catogry
- wordpress wp_list_categories
- wp_dropdown_categories and custom taxonomy + custom post type
- Get all sub-categories of a parent category
- Introductory paragraph only in list of blog posts
- Check child/parent categories if exists
- Show Available Taxonomy List with Current Category
- WooCommerce Grid / List view
- custom walker wp menu last element
- Display the last post by each category?
- To get list of bottom most or deepest or last child for specified parent category
- List all categories with featured image from post?
- List categories with custom code
- limit a list of tags to one category [closed]
- Categories list loop – add separator every 3 categories [closed]
- how to wordpress When I click on the category link, subcategories appear
- new WP_Query all post in a category inside the loop
- get listed category’s id?
- List Child Categorie and hide the parent
- Adding category dropdown list to theme options page
- Hide specific category from wp_list_categories
- How do I add a separator to my list of terms with get_category
- How to show a list of only categories (exclude subcategories)
- Category list with postcount
- List first letter of categories – issue upon spcecial characters (danish letters)
- How do I create an alphabetically organized glossary of links?
- Highlighting Current Category in the Archive and Feeds page
- Generate a nested list of all posts, sorted first by year, then by month
- adding a #hash to each link in list_pages()?
- Getting the posts list visualised in categories tree
- display the months of a specific category
- Return all Tags and Categories in Separate List
- get taxonomy list in a page in the wordpress
- List all taxonomies with their descriptions
- How correct list-style displayed in firefox? [closed]
- How Can Hide Define Category in Post Contents?
- AZ Directory category
- Search tag within category
- Wrap Meta Box with and for each new line
- Listing category
- get_all_category_ids for bookmark
- Add thumbnails in ‘li’ list
- List products from current category
- Way to show content of a post, but if exceeds character limit revert to excerpt?
- List posts that are in the same category as the current post title
- list taxonomy based on taxonomy
- List child pages alphabetically
- How to make a text string into a bullet list [closed]
- How to display my categories in a list (to a post, not the sidebar)?
- Moving Blog and Changing URL
- Finding and replacing elements in a list
- Element-wise addition of 2 lists?
- Exclude a category from WP_Query
- Custom Single Post By Category
- How can I create a loop to build slides based on multiple categories using Coda Slider
- Filtering by Category doesnt paginate correctly on the backend
- Display post category in foreach loop with category link
- List all the categories with or without post
- How do I get the sub categories of the parent when in a sub category?
- Automatically redirect a page to a category that share the same slug
- JSON REST API WordPress only showing first 10 categories
- How to obtain the recent posts without their content in an efficient way?
- Child Category Image
- Stores category posts in an array
- line order number start numbering from second line (SOLVED)
- Edit tag_id in category pages of dashboard
- wp_list_categories with category description
- Query posts by views on category page
- Custom Page Template Category loop not functioning correctly
- How to correctly display category’s slug as a class?
- prefix to post permalinks without affecting category permas
- Categories In English version showing not canonical URL, instead shows query search result
- How to change current category to another in wordpress
- How to modify custom category field from front end?
- Adding Custom Post Types to category/tag/author archives breaks header content
- Category name as page title
- If it is a top level category show children otherwise show sibling categories
- (WordPress) How to get custom taxonomy parent name?
- How to make a drop down menu with categories
- How to Include a common category in a custom Category Search
- Make a menu visible for a single category and it’s content