WordPress.org

Ready to get started?Download WordPress

Forums

Remove comma from wordpress categories!!! (2 posts)

  1. nikhu07
    Member
    Posted 1 year ago #

    Hi, I want to remove comma between categories displayed on my home page http://thedripple.com below titles of post!

    I'm using the following code to display categories..

    <?php $parentscategory ="";
    foreach((get_the_category(' , ')) as $category) {
    if ($category->category_parent == 0) {
    $parentscategory .= ' <a class="cat-post-before" href="' . get_category_link($category->cat_ID) . '" title="' . $category->name . '">' . $category->name . '</a>, ';
    }
    }
    echo substr($parentscategory,0,-2); ?>
  2. vtxyzzy
    Member
    Posted 1 year ago #

    I do not see categories below the titles on your home page. Did you remove them?

    In your code above, the comma seems to be coming from near the end of this line, following the closing '/a' tag:

    $parentscategory .= ' <a class="cat-post-before" href="' . get_category_link($category->cat_ID) . '" title="' . $category->name . '">' . $category->name . '</a>, ';

Topic Closed

This topic has been closed to new replies.

About this Topic