Site logo

Archived topic

Entry Meta Items different for one categories single posts

3 replies · Started by webcréateur on February 17, 2020

Viewing posts 1–4 of 4

Hi there,

We added following filter to output entry meta of single posts and archive view:

add_filter( 'generate_header_entry_meta_items', function() {
    return array(
        'categories',
        'author',
    );
} );

This works fine so far!

Now we want to output the meta "date" only for one categories (ID 4651) posts and archive.

I tried something like this and set a higher priority to the snippet, but it won't work:

add_filter( 'generate_header_entry_meta_items', function() {
	 if (is_single() && in_category('4651')) {
    return array(
        'categories',
	'author',
        'date',
		);
		 }
} );

Any Ideas how to solve this?

Best regards!

Hi there,

try combining the function:

add_filter( 'generate_header_entry_meta_items', function() {
    if (is_single() && in_category('4651')) {
        return array(
            'categories',
            'author',
            'date',
        );
    } else {
        return array(
            'categories',
            'author',
        );
    }
} );

Thanks a lot, David. That worked great! :)

Glad to hear that

This archived topic is closed to new replies.