Grow your CSS skills. Land your dream job.

WordPress – Linking two different style sheet

  • # February 10, 2010 at 8:13 pm

    Hi
    Does anybody can tell me how do I link in WordPress to two different pages to different style sheet.I would like to have different layout in home page but rest of the pages would remain and have defaults styles.css.Where do I place link that link up external sheet for it? WordPress is using same styles everywhere .Any help or suggestions here please?
    Thnax

    # February 10, 2010 at 9:52 pm

    1. Find the id number of the page you want the special stylesheet to go to.

    2. Open up header.php and find where your stylesheet is being linked from.

    Change:

    Code:
    Code:
    < ?php if ( is_page(id#) ) {
    echo '
    # February 11, 2010 at 7:09 am

    Well is not working :-( … any ides on this one?

    # February 11, 2010 at 12:38 pm
    "markito" wrote:
    Well is not working :-( … any ides on this one?

    Just to make sure my PHP is wrong and nothing else, did you replace "id#" with your home page’s id?

    # February 11, 2010 at 12:44 pm

    Silly me, I see the problem here!

    Give this one a go:

    Code:
    < ?php if ( is_page(id) ) {
    echo ' ‘;
    }
    else {
    echo ‘ ‘;
    }
    endif ?>
    # February 11, 2010 at 3:15 pm
    Code:
    < ?php while (have_posts()) : the_post(); ?>
    < ?php if (is_paged()) : ?>
    < ?php $postclass = ('post'); ?>
    < ?php else : ?>
    < ?php $postclass = ($post == $posts[0]) ? 'featured-post' : 'post'; ?>
    < ?php endif; ?>

    # February 11, 2010 at 5:14 pm

    I don’t think you understand what the OP is asking for.

    Here’s another one, from Chris’ book Digging into WordPress.

    Conditionally loading extra CSS files

    Code:
    < ?php if (is_page_template("page-snippet.php")){ ?>

    href="/css/snippets.css” />
    < ?php } ?>
    # February 11, 2010 at 5:31 pm

    Since you want it to act on the homepage you should replace is_page_template("page-snippet.php") with is_front_page().

    # February 11, 2010 at 5:36 pm
    "davesgonebananas" wrote:
    Since you want it to act on the homepage you should replace is_page_template("page-snippet.php") with is_front_page().

    Yes, sorry, forgot to update that. Too quick with my copy and paste!

    Should also mention that when using that method, it means you’ll have two stylesheets being loaded at the same time.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".