Site logo

Archived topic

Display category meta next to date

5 replies · Started by Emma on December 14, 2018

Viewing posts 1–6 of 6

Hi, I would like to know how to display the category meta next to the date on my blog posts (exactly like it is on the blog page of your Aspire template). I can't find any setting anywhere to display it like this. I can see in previous support topics that there is code you can add to move the category meta below the title, but I can't see any way to display it next to the date like this. Is there a simple setting to do this or does it require coding?

Hi Emma,

Give this function a shot:

add_filter( 'generate_post_date_output', function( $date ) {
    echo $date;

    $categories_list = get_the_category_list( ', ' );

    if ( $categories_list ) {
        echo '<span class="categories">' . $categories_list . '</span>';
    }
} );

Then you can add some space around it like this:

.entry-meta .categories {
    padding: 0 10px;
}

Let me know if that helps or not :)

Thank you, it's almost perfect, it's just missing the line between the date and the category. Also, I only want this on the posts on the blog page and not the single post. (exactly how it is on the Aspire template). Thanks :)

Try changing your function to this:

add_filter( 'generate_post_date_output', function( $date ) {
    if ( is_singular() ) {
        return $date;
    }

    echo $date;

    $categories_list = get_the_category_list( ', ' );

    if ( $categories_list ) {
        echo ' | <span class="categories">' . $categories_list . '</span>';
    }
} );

Let me know :)

That's sorted it, thanks!

Awesome, glad I could help :)

This archived topic is closed to new replies.