Archived topic
Double category/tag in blog archive
5 replies · Started by Sean on June 7, 2022
I'm trying to display the categories/tags beneath the featured image in my blog archive. I achieved this in
Appearance > Customize > Customize > Blog and adjusting the checkboxes for displaying post categories and tags.
It works fine but now I get two copies of them.
This second copy error happens when I add PHP to make each single post display the categories and tags below the title:
add_filter( 'generate_header_entry_meta_items', function() {
return array(
'categories',
'tags'
);
} );
(I don't want to show the author/date)
I also have CSS added to make the folder icons and spacing:
.entry-header .cat-links,
.entry-header .tags-links {
display: block;
}
.entry-header .cat-links:before,
.entry-header .tags-links:before {
display: inline-block;
}
Website is http://www.remembryo.com
Hi there,
Try change your PHP code to this:
add_filter( 'generate_header_entry_meta_items', function($item) {
if (is_single()) {
return array(
'categories',
'tags'
);
}
return $item;
} );
Let me know :)
Thank you! But it didn't work :(
I tested the code on my site, it does remove the duplicated categories and tags on archive page.
Can you make sure cache is cleared? If you have server level cache, please clear that as well.
And did you remove the original code?
Oops, you're right, clearing the cache did it. Thank you!
Glad to hear that :)