• I want to display the category of each post in the beginning of the title, example: “Category – Subject”, “Movies – Spider Man review!” .

    I know a code:

    <?php
    foreach((get_the_category()) as $category) {
    $category_name = $category->cat_name;
    }
    echo ‘Category ‘ . $category_name . ‘ Movies ‘ . $post->title;
    ?>

    But I always choice two categories, they are “the category” and “it’s parent”
    I don’t want to let the Category’s Parent display.
    *example: Entertainment – Movies
    Entertainment is Movies Parent.

  • The topic ‘Display category in post title?’ is closed to new replies.