WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] need a code for external stylesheers per page_id (5 posts)

  1. Ramzii
    Member
    Posted 3 years ago #

    After hours of modding and searching I found this:

    <?php if (is_page(1)):?>
    <link rel="stylesheet" href=<?php echo bloginfo('template_directory'); ?>/css/svib.css" type="text/css" /> <?php else:?> <link rel="stylesheet" href="<?php echo bloginfo('template_directory'); ?>/css/index.css" /> <?php endif;?>

    And guess what, it aint working.

    My css files need to differ per certain pages, how do I accomplish this??
    All help is appreciated thanks a bunch.

  2. Ramzii
    Member
    Posted 3 years ago #

    bumpersticker

  3. Ramzii
    Member
    Posted 3 years ago #

    so..no one knows?

  4. Ramzii
    Member
    Posted 3 years ago #

    Seriously.. it wasnt that hard of an answer:

    //switch depending on the page_id
    switch($_GET['page_id'])
    {
    //if page_id is id1, use stylesheet1
    case 'id1':
    echo "<link href='stylesheet1.css' rel='stylesheet' type='text/css' media='screen' />";
    break;
    
    //if page_id is id2, use stylesheet2
    case 'id2':
    echo "<link href='stylesheet2.css' rel='stylesheet' type='text/css' media='screen' />";
    break;
    //etc.
    //if it is none of them, the default should be this stylesheet: (this can be removed)
    default:
    echo "<link href='defaultstyle.css' rel='stylesheet' type='text/css' media='screen' />";
    }

    Hope someone saves a heap of time and finds this topic.

  5. pushpinderbagga
    Member
    Posted 2 years ago #

    The one you started with works

    you just put a : instead of a ;

    This one works for sure

    <?php if (is_page(1)); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic