How to hide bylines in posts under selected categories?
-
I don’t want posts under certain categories to display a byline (Author Name). Can this be done? Of course I can use Pages for these Posts, but then I don’t know whether pages can be put under categories and handle them as such. Any help will be greatly appreciated. Thanks.
-
Hello @zebracrossing
Can you please share what is the URL you need help with?
That will help me suggest the best way to implement this for you.
Please let me know if you have any questions.The site handles a project for curating/digitalising a 1000 newspaper articles. The curated articles are our blog posts per se, and they belong to the category ARTICLES. This needs to display the curator’s (author’s) name. An example URL:
https://zebracrossing.online/7458/The site has a section that contains updates on topics specifically covered by the articles. Updates are added by editors, under a category named SEQUELS. There could be more than one update related to an article, which means display of a single byline won’t be proper. Example:
https://zebracrossing.online/5002/We need to hide byline on posts like this (under SEQUELS.)
Unfortunately, it’s not that easy. Looking at the page, it is unclear to me where the “Photo by …” output comes from. Because it is in the content of the article.
Do you know which plugin is responsible for this? Then you would have to contact their support.
Oh, I am sorry. “Photo by Tadeusz Lakota on Unsplash” is in the post (part of text). We wanted to use that photo for the article assigned for that page. I will provide another example, where I don’t want the by line.
https://zebracrossing.online/7228/I am toying with an idea.
Let a single post check category.
if ( is_category( ‘blog’ ) ) {
echo ‘AUTHOR NAME’
} elseif ( is_category( ‘sequels’ ) ) {
echo ‘NOTHING’;
}Thanks.
In your new example, I don’t see what the “byline” should be? Can you provide a screenshot and highlight it? See: https://wordpress.org/support/forum-user-guide/block-editor/#adding-screenshots
I meant Author Name adjacent to the Avatar.
You could hide this using CSS. Example:
.single .entry-meta > span.author-avatar, .single .entry-meta > span.author {
display: none;
}To be added under Appearance > Customizer > Additional CSS.
I had located it under Inspect, however…
I want the Display on posts under Category Blog.
I don’t want the Display on posts under other categories.I’m not sure what you mean by the blog category. A blog is more of an overview of the blog posts. Creating a category for this is rather unusual. In your example post, I also don’t see any feature that could indicate this category. Or are you talking about posts in general?
What I said above follows my original post. We are into a project: curating/digitalizing 100s of articles authored by one person for a research-oriented column in a newspaper. So the categories are like:
Category: ARTICLES. This carries the digitalized articles ready for a website. Since all of them are written by a single person, Display of author name is not necessary. Maybe the Display could be like, “Curated by John Doe”.
Category: BACKEND. This contain SITE pages. This section contains notes from the TEAM engaged in the project. This doesn’t need a Display, or it could be just “By TEAM ZEE”.
Category: SEQUELS. Several of us are ResearchGate members, and several RG scholars are interested in the site. This category follows latest research in the topics covered in the newspaper column (Updates to Category: ARTICLES). This requires a typical byline Display, like “By Naomi Rilke”.
I currently see 10 categories for your posts. One of them is a category that has the slug “blog”, but the title “Collection” (which confuses me, because WordPress itself is a blog). If I understand correctly, you want to hide the author for all posts that are assigned to the Collection (or “blog”) category?
This would be possible via CSS, but only if the theme you are using would also output information (a CSS class) about the categories used by the post in the source code. Unfortunately, this is not the case.
So you have 2 options here:
- Contact the support of the theme you are using and ask for a corresponding addition. You could then use CSS to set the condition for hiding the author.
- Add the information about the categories used by the post yourself with individual CSS using PHP. An example of the implementation can be seen here: https://stackoverflow.com/questions/45972062/add-multiple-categories-to-body-class-wordpress – then you could also set the desired condition in the CSS.
The biggest paradox I have come across is that I originally built the site using a theme that’s not supported since 2000, but it’s more advanced than any of the 100s of the newer themes I have seen so far. It was created with astounding foresight and structural aesthetics. It has survived all the WP and PHP versions as of the moment, and it works with WP patterns with no the least conflict. It has features unthinkable for Block Age theme builders. All the 10 categories serve a purpose in that theme. And to be frank with you, I will use that theme for my site until it’s outdated.
The current theme that I use doesn’t have that many features, but it gives me ample opportunity to use WP Patterns on the Home Page. It’s my backup solution.
‘Collection’ is an apt word for curated material. And what the site does is curating a 1000 articles that appeared in a newspaper column which started jubilantly a quarter century ago with a quiz contest session that was sponsored by Discovery Channel. It’s a national record.
For the time being I am using the code
.single .entry-meta > span.author-avatar, .single .entry-meta > span.author {
display: none;
}Thanks a lot for your time.
LET ME REPHRASE THE QUESTION WITH NO REGARD TO ANY SPECIFIC THEME.
I have 3 distinct categories of posts and I want the Author”entry meta” differently for each — preferably using IF and ELSEIF.Category 1 should display something like “Curated by JANE DOE”.
Category 2 should display jusy “By JANE DOE”.
Category 3 should leave “entry meta” empty.
Can someone help with the coding?I intend to go to the File Editor and directly write it into the file concerned. I will take the necessary precautions.
Some theme makers intentionally update a theme now and then, with nothing substantially new, just to discourage the users of the free edition of the theme. Most themes are not updated frequently.
The topic ‘How to hide bylines in posts under selected categories?’ is closed to new replies.