0

How can I hide just the author from the post meta in search results, while keeping the date and categories?

I know I can use something like:

.post-meta .author { display: none; }

to hide the author name, but that still leaves me with "by" and a vertical separator before the date.

"by" and the separator are not linked to any class, so how can I target and hide them, without hiding the entire .post-meta?

I'm using Divi, if that matters, and here is the full markup of the meta section:

<p class="post-meta">by <span class="author vcard"><a href="[link to author page]" title="Posts by [me]" rel="author">[my name]</a></span> | <span class="published">Jun 3, 2019</span></p>
  • Your best bet would be to edit the template that is generating the post meta, then you could display exactly what you want. – RiddleMeThis Sep 6 at 19:59
  • The structure of the HTML means that you can't do this with CSS. You'll need to change the template. – Jacob Peattie Sep 11 at 9:51
0

As stated in my comment the best solution would be to create a child theme and edit the file generating the post meta. This would give you full control of what is being generated and you won't have to worry about hiding unwanted content via CSS.

However, you could hide the text nodes and show the elements you want by doing something like this...

    .post-meta {
        visibility:collapse;
    }

    .published {
        visibility:visible;
    }

Note: The above hidden items will still keep their space in the DOM, so you could add float:left to .published to break the flow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.