Archived topic
Single Post Custom Category Meta Not Showing (After Update)
25 replies · Started by Rohan Verma on October 15, 2020
So the CSS in that topic is targeting an element like this:
<div class="entry-meta cat-links">
...
However, that's not our default structure, it should look like this:
<div class="entry-meta">
<span class="cat-links">
...
So, the CSS from that topic never should have worked in the first place unless you had altered the HTML structure.
If you're not sure how the HTML was altered, you can change all instances of this in your CSS:
.entry-meta.cat-links
To this:
.entry-meta .cat-links
It seems that the category meta is already showing at the bottom of the article in the custom look instead of the default look.
Pushing that at the top and restoring the default category meta at the bottom is required.
Screenshot: https://prnt.sc/vaumkt
Ok, so to confirm:
1. You want the list of categories with the custom look to be above your title on single posts.
2. You also want the list of categories with the default look to be in the footer of your single posts.
Were you accomplishing this before updating to 3.0? If so, how? The topic you linked to didn't have any code that would move the categories away from their default location.
Yes.
How were you doing this previously? I want to make sure the code we provide doesn't conflict with what's already there.
There is no code in that topic that would move the categories above your post title. It only has CSS for styling the category items.
To add categories above the title, we could try this:
add_action( 'generate_before_entry_title', function() {
if ( is_single() ) {
echo '<div class="entry-meta">';
generate_do_post_meta_item( 'categories' );
echo '</div>';
}
} );
Does that do the trick?
Yes it does.
But the box format isn't there like before. Can you suggest just like this one: https://generatepress.com/forums/topic/look-of-single-post-category/
Can you try the updated code?: https://generatepress.com/forums/topic/single-post-custom-category-meta-not-showing-after-update/page/2/#post-1525934
Yes. Now, looks fine.
But the same meta is also appearing at the bottom of the article along with the default meta. How to remove the bottom one?
Can you try unchecking the option in the customizer first?
https://docs.generatepress.com/article/blog-content-layout/#single
Let me know if it somehow removed both :)