Site logo

Archived topic

Disabling titles in headers for specific posts

3 replies · Started by ch1800 on May 4, 2022

Viewing posts 1–4 of 4

Hello,

I'm using <h1>{{post_title}}</h1> in post headers with a Header Element and would need to disable this title in some posts - not all of them.
Would this be possible?

I cannot make exceptions for those posts in Display Rules of this Element as this would affect all other settings as well.

Thanks.

Hi there,

You can try creating a duplicate of the Header Element without the <h1>{{post_title}}</h1>, and then displayed to the specific pages you prefer. Then, exclude these pages/posts in your original Header Element.

You may also do this through CSS, you’ll just need to get to post id or page id:

post:

body.postid-5729 .inside-page-hero h1 {
    display:none;
}

if page:

body.page-id-2621 .inside-page-hero h1 {
    display:none;
}

combined:

body.page-id-2621 .inside-page-hero h1, body.postid-5729 .inside-page-hero h1 {
    display:none;
}

multiple:

body.page-id-2621 .inside-page-hero h1, body.postid-5729 .inside-page-hero h1,
body.postid-5730 .inside-page-hero h1,
body.postid-5731 .inside-page-hero h1 {
    display:none;
}

As shown, you may apply the rule to multiple posts/pages, you’ll just to separate the selector with a comma.

Here is an article with regards to adding CSS: https://docs.generatepress.com/article/adding-css/#additional-css

Adding this through additional CSS should work.

How to get the page/post id: https://kinsta.com/blog/wordpress-get-post-id/

Hope this clarifies. :)

Many thanks Fernando,

I also initially thought of doing what you suggest in your first para but this looks a bit overkill.
I finally got inspired by your CSS suggestions and ended up simply using this at each individual post separately:

.inside-page-hero {
    display: none;
}

That works fine and thanks again!

You’re welcome! Glad you found a more apt solution! Feel free to reach out anytime you’ll need assistance with anything else. :)

This archived topic is closed to new replies.