• Resolved ibart

    (@ibart)


    Hi there guys.

    I need help in creating a php script for using one css tyle on homepage for a slider and then to change it to a different one for the rest of pages.

    example:
    homepage:
    stylemain.css

    any other page:
    stylemini.css

    Please help..

Viewing 5 replies - 1 through 5 (of 5 total)
  • are those stylesheets meant to be linked instead of style.css or after it?

    are you referring to ‘page’ as in ‘webpage’ or as in ‘static page’ in the way it is used within WordPress?

    start by looking at conditional tags:
    http://codex.wordpress.org/Conditional_Tags

    Thread Starter ibart

    (@ibart)

    It’s a static page in wordpress

    Thread Starter ibart

    (@ibart)

    it might be something like

    if is_home() stylemain.css
    if is_home() not found display stylemini.css

    just don’t know how to put it all together 😉

    the code needs to be entered into the <head> section of your theme, likely in header.php;
    example:

    <?php if( is_home() ) : ?>
    <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/stylemain.css" type="text/css" media="screen" />
    <?php else : ?>
    <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/stylemini.css" type="text/css" media="screen" />
    <?php endif; ?>

    http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

    Thread Starter ibart

    (@ibart)

    <?php
      if(is_home()){
        // we are on the home page
        echo '<link rel="stylesheet" src="css/stylemain.css" />';
      }else {
        echo '<link rel="stylesheet" src="css/stylemini.css" />';
      }
    ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Attaching different css style to homepage and the rest of pages’ is closed to new replies.