css edit to remove title on home page only

Hello,
I'd like to remove "Home" page title on my home page with css.
But I'd like to do it in a way that when you search for "test" then you see “test” Search Results text.
How can I do that?

Cheers,
Marcin

  • Jude
    • DEV MAN

    Howdy @Marcin

    Here is some code that can help

    add_action('wp_footer', function(){ echo "jQuery(\"h1:contains('Home')\") .hide()" ; } ) ;

    Just copy/paste the code into the functions.php file of your child theme or a site specific plugin if you use one.

    Jude

  • Patrick
    • Support Monkey

    Hi there @Marcin

    I hope you're having a great day!

    You do that by getting specific and including the body class in your selector. WordPress automatically adds a number of classes to the body element of every page of your site to help you specify them in your CSS.

    As you might have guessed, the homepage has it's own class: home

    So you can easily hide the page title on the homepage only, while keeping it visible everywhere else, like so:
    .home .page-title {display:none;}

    The screenshots below show where you can easily find the classes and/or IDs you can use in your 'custom CSS. You'll also see in the 2nd screenshot that the search results page has a different body class: search

    Open your browser's developer tools and have some fun checking out different areas on your site, and the various elements on different pages.

    I hope this helps! And thanks for being a member :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.