• Resolved rickmesser

    (@rickmesser)


    Hi,

    Could really use some help.

    New to Word Press/PHP, good with XHTML/CSS.

    I’m wondering how to link a page template to a different css file. Do I just create a different header and reference another style sheet? If so, do I just create another style sheet (called whatever I want) in the stylesheet directory?

    Here’s what I want to do…
    Creating a theme and want inside pages/blog/homepage to pretty much look the same except for 1 child that will have a MUCH different look as far as styling which is why I want a totally different style sheet.

    I’ve looked up some keywords in codex and these forums but I can’t seem to find exactly how to do this.

    Can anyone help?
    Thanks for any suggestions!

Viewing 5 replies - 1 through 5 (of 5 total)
  • You could use the is_page() conditional in header.php to determine which stylesheet to call.

    <?php if( is_page('Foobar') ) :?>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />
    <?php else :?>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/alternate.css" media="screen" />
    <?php endif;?>

    https://codex.www.ads-software.com/Conditional_Tags

    Thread Starter rickmesser

    (@rickmesser)

    Thanks for the brief response Esmi! I will try this and let you know! I really appreciate it.

    Thread Starter rickmesser

    (@rickmesser)

    Ok, sorry it took a couple days, but I had some hosting issues that were preventing me from testing this out. All fixed now with a new host.

    I tried it, but for some reason it’s applying to all pages now? Check it out:
    https://www.achildssong.com/2010/

    The homepage has a different page template including a different header so it’s not affected. The blog is on the “post-a-note” page. I only want the page “The Studio” and all sub pages of “The Studio” to have the different style sheet. Do you know where I’m going wrong?

    Here’s your code I put into my header with actual file names:

    <?php if( is_page('the-studio') ) :?>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" />
    <?php else :?>
    <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/studio_style.css" media="screen" />
    <?php endif;?>

    I don’t know if it matters or not, but since this is the first wordpress site I’ve ever tried to build on my own, I’m basing it on the framework of kubric.

    Obviously, I need to make a header (page template) specifically for the studio as that section doesn’t need those graphics at the top.

    Hey! Since I’m creating a new header for this page and sub pages, should I just put code in “The Studio” header to get that stylesheet?
    What would the code be??

    Thank you so much.

    Thread Starter rickmesser

    (@rickmesser)

    OMG! Ha ha.

    After I posted, I checked again and realized it’s working backwards! ha! The style sheet I want attached to “The Studio” is applying to everything EXCEPT the studio! What did I do wrong!? Ha, that’s an ironic outcome!

    I will play around with it. Do you know what I did wrong?

    Thread Starter rickmesser

    (@rickmesser)

    Flipped it around and it works great! Thanks! In the end, I just pointed the new header “template page” to a different stylesheet. Then I just assigned all children I created to have that template. I just didn’t know that you could assign a different style sheet so easy!!

    Thank-you for your help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘specific templates to reference 2nd style sheet?’ is closed to new replies.