Forums

[resolved] My second Page looks different from my first. (8 posts)

  1. Fredber
    Member
    Posted 9 months ago #

    I have a
    #header h1 { display:none }
    in my style.css which works on my Page1 (used as static home page)

    This hidden function doesnt work on the second page which I am currently making. The header is displayed there, as if the style.css doesnt apply?

    Frederick

  2. peredur
    Member
    Posted 9 months ago #

    Can you post a URL so we can have a look at the problem?

    Styles are applied in CSS in response to applying a set of rules of inheritance and specificity, within the cascade. It's actually simpler than it sounds, but people coming to it for the first time often find it a bit confusing.

    In this case I can't give specific reasons because I can't see the problem or the code, but let's say you altered a rule the was simply, as you say:

    #header h1 {display: none;}

    If there was another rule elsewhere that varied even slightly from this, for instance like this:

    div#header h1 {display: block}

    ... it would take precedence because it is more specific.

    What's more, if there was a rule later on in the style sheet after the rule that you altered, that had exactly the same specificity as the rule you altered, it would take precedence because it was later in the cascade.

    However, also in general terms, in this case I would not hide the h1 element, I'd take it out of the HTML. You'll need to use some PHP code to do that since you don't want to eliminate it from all your pages, it seems. To do it, you'll just need to identify the PHP file that is outputting the heading and use some WP conditional tags to not output it on the front page.

    As ever, I advise strongly that you do all this in a child theme.

    Cheers

    PAE

  3. Fredber
    Member
    Posted 9 months ago #

    The site is http://www.warhammernorge.com

    Im using a Child Theme of twentyten.
    Header.php, page.php, functions.php and style.css have their new folders in the child theme.

  4. peredur
    Member
    Posted 9 months ago #

    OK, looking at your site, I see it's the site title that you don't want to display. This is output from header.php:

    <hgroup>
    <h1 id="site-title">
    <span>
    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo
    esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
        <?php bloginfo( 'name' ); ?>
    </a>
    </span>
    </h1>
    <h2 id="site-description">
        <?php bloginfo( 'description' ); ?>
    </h2>
    </hgroup>

    The site title is in the h1 element and the site description in the h2 element.

    If you don't want either or both of them to appear anywhere on your site, just delete the corresponding code from header.php (in the child theme). If you need it to appear selectively, you'll need to use some conditional tags to make sure it only outputs on the pages you want.

    If you want to be sure your changes are never going to be overwritten by updates to the child theme you're using, you would need to copy all its files to a new folder with a new name and then alter the comments at the top of style.css (in your new folder) to suit. This new theme should then show up in your Dashboard and you can activate it.

    HTH

    Cheers

    PAE

  5. Fredber
    Member
    Posted 9 months ago #

    What I did was put the following into style.css

    /*Hide Site Title start*/
    #header h1 { display:none }
    /*Hide Site Title end*/

    Should I remove it from style.css and put it into header.php instead?

    Frederick

  6. alchymyth
    The Sweeper
    Posted 9 months ago #

    twenty ten switches from h1 to div after the front page;

    the suitable css selector is #site-title :

    #site-title { display: none; }

  7. Fredber
    Member
    Posted 9 months ago #

    Thanks! :)

  8. peredur
    Member
    Posted 9 months ago #

    What I would do is to remove the code that displays the site title, if you don't want it ever to appear on your site.

    In other words, I would delete this code from the header.php file:

    <h1 id="site-title">
    <span>
    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo
    esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
        <?php bloginfo( 'name' ); ?>
    </a>
    </span>
    </h1>

    If you also want to make sure the site description never displays, I'd also delete this:

    <h2 id="site-description">
        <?php bloginfo( 'description' ); ?>
    </h2>

    Quite possibly you could safely delete the whole of the <hgroup> element.

    HTH

    PAE

Reply

You must log in to post.

About this Topic