Tester with Input Information from web

April 30, 2025

To display WordPress categories in a paragraph with comma separators instead of bullet points, you need to modify the code that displays them.You can use the the_category function, but change the separator parameter. Here's how: 

  1. Identify the Code: Locate the code in your theme's template files (e.g., single.phparchive.php) that's responsible for displaying the categories. It likely uses the_category() or wp_list_categories.
  2. Modify the Separator: Use the the_category() function and specify a comma as the separator:

Code

    <?php the_category(', '); ?>

This will display the categories separated by a comma and a space. You can adjust the separator as needed. 

  1. Optional: If using wp_list_categories: Instead of wp_list_categories, which defaults to a list, you can use get_the_category() and implode() to achieve the same result:

Code

    <?php
$categories = get_the_category();
$category_names = array();
foreach ($categories as $category) {
$category_names[] = $category->cat_name;
}
echo implode(', ', $category_names);
?>

Example:

If you have the following code:

Code

<?php the_category(); ?>

Replace it with:

Code

<?php the_category(', '); ?>

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram