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
- How can I reverse a list in Python?
- Difference between del, remove, and pop on lists
- How can I reverse a list in Python?
- What is the difference between Python’s list methods append and extend?
- Python – TypeError: ‘int’ object is not iterable
- Understanding slice notation
- Understanding slice notation
- TypeError: list indices must be integers or slices, not str
- IndexError: list index out of range and python
- Python – TypeError: ‘int’ object is not iterable
- How to convert list to string [duplicate]
- How do I get the number of elements in a list?
- Difference between del, remove, and pop on lists
- How to overcome TypeError: unhashable type: ‘list’
- How to avoid “ConcurrentModificationException” while removing elements from `ArrayList` while iterating it? [duplicate]
- Finding the index of an item in a list
- Difference between Arrays.asList(array) and new ArrayList
(Arrays.asList(array)) - Finding the index of an item in a list
- Accessing the index in ‘for’ loops?
- How to make a flat list out of a list of lists
- Convert list to array in Java [duplicate]
- Removing duplicates in lists
- TypeError: list indices must be integers or slices, not list
- Accessing the index in ‘for’ loops?
- What does the list() function do in Python?
- List changes unexpectedly after assignment. Why is this and how can I prevent it?
- Why does this iterative list-growing code give IndexError: list assignment index out of range?
- Converting array to list in Java
- TypeError: ‘float’ object is not subscriptable
- Is there a short contains function for lists?
- How to get the list of all installed color schemes in Vim?