• Resolved mintertweed

    (@mintertweed)


    I currently have one stylesheet for my website, here. I want to have a second stylesheet only recognized by the “Feel Good Candy” page, under “Graphic Novels & Written Novellas.” I know how to make a second stylesheet in WordPress, but how do I make “Feel Good Candy” recognize it? Thank you in advance! I have never done this before, so forgive me if it is something terribly easy to do. Basically, I was going to make a new HTML page with a fresh CSS stylesheet in WordPress. I have made a new HTML page before, but since it involved so little CSS, I just had the CSS in the HTML code. This time I want to do it right (by calling the new CSS stylesheet for that specific HTML page). I want everything to change, from the background, to the “Minter Tweed” logo, to the slogan below that, and the font type. Everything. Thank you in advance!

Viewing 6 replies - 1 through 6 (of 6 total)
  • In general, there are two ways to do what you want — make a separate CSS file that is only linked to that page in the header. In the header.php file you can only get that stylesheet if the page id is feelgoodcandy.

    Or just code the CSS in the regular stylesheet so that it only applies to that page — since the page has the id “feelgoodcandy” you can include that id in every CSS style for that page — i.e.

    #feelgoodcandy whatever tags or classes or other ids {
    styles...
    }

    Thread Starter mintertweed

    (@mintertweed)

    I would rather create a whole separate CSS stylesheet. I am fairly organized when it comes to my CSS code, but I think it would be best to create a second CSS stylesheet. I already know how to create another CSS stylesheet, but how do I make the “Feel Good Candy” page recognize it? What do I write in the “header.php” file? And is this in the main “header.php” file for my current website or do I need a whole new one? Thank you for your help thus far!

    make a separate CSS file that is only linked to that page in the header

    in header.php of your theme, below the line with ‘<link rel=”stylesheet” href=”….’, add for example:

    <?php if( is_page('Feel Good Candy') ) : ?>
    <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/feelgoodcandy-style.css" />
    <?php endif; ?>
    Thread Starter mintertweed

    (@mintertweed)

    Thank you for the directness of your help. Like I said before, I am rather new to this, so having the code I need and being told where to put it is exactly what I was looking for. Thank you once again!

    <?php if( is_page(‘Feel Good Candy’) ) : ?>

    So, instead of ‘Feel Good Candy’ would it actually say ‘feelgoodcandy’ since that is how the page is referred to in my previous code?

    Edit: Nevermind. I see it accepts both. Awesome sauce! Thank you so much.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    the is_page() references the page name.

    Thread Starter mintertweed

    (@mintertweed)

    Ah, I understand now. Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Recognizing CSS Stylesheets’ is closed to new replies.