Support » Themes and Templates » Need help with Stylesheet Url in WP!

  • Resolved pookey

    (@pookey)


    Hi!

    I have created a random background php script in my theme which is working. I want to do the same with my css. The only problem is how do I link it to my header?
    With the random background script, I added <?php include(“background.php”);
    ?>
    before anything else in my header.php. I also added <body background=”<?=$_SESSION[‘background’]?>”> after </head>.

    But with my CSS?

    I know I have to include this <?php include(“css.php”);
    ?>

    But what about my $_SESSION[‘css’]?

    It should be added here somewhere? and how? href=”<?php bloginfo(‘stylesheet_url’); ?>”

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Confused.

    What’s in background.php? css.php?

    Mate, am really confused the way you telling the story.

    Thread Starter pookey

    (@pookey)

    Oh sorry..

    The bakcground.php is creating a random background image per session..

    background.php:

    <?php
    session_start();
    
    if(!$_SESSION['background'])
    $_SESSION['background'] = 'url/portfolio/wp-content/themes/portfolio/background/background' . mt_rand(1, 5). '.jpg';
    
    ?>

    I thought I could do the same with my css..

    css.php:

    <?php
    session_start();
    
    if(!$_SESSION['css'])
    $_SESSION['css'] = 'url/portfolio/wp-content/themes/portfolio/css' . mt_rand(1, 3). '.css';
    
    ?>

    So as I said, for the random background script, I added

    <?php include("background.php");
     ?>

    before anything else in my header.php.

    I also added

    <body background="<?=$_SESSION['background']?>">

    after </head>.

    But I don’t know how to include the css.php in my header..

    Then,

    1. Add <?php include("css.php"); ?> somewhere around <?php include("background.php"); ?>
    2. Add <link rel="stylesheet" href="<?=$_SESSION['css']?>" type="text/css" media="screen" /> anywhere between <?php include("css.php"); ?> and </head>

    Thread Starter pookey

    (@pookey)

    Thank you!, but it does not work.. I think it’s because I still have <link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” /> in my header.php..

    And if I remove it, the page will be shown without css! I also heard that wordpress needs the style.css file in the theme folder?

    Basically, it does. Otherwise it will report it as incomplete theme. The minimum that a theme needs = index.php + style.css.

    Thread Starter pookey

    (@pookey)

    So it won’t work, and I have to put the css files in an array instead and have them in the main folder?

    Or can I put some kind of link to the php code/file inside style.css?

    Or is it any other ways I can use? Does anyone know?

    Thanks for the answers poppacket and moshu..

    Try to change the position of <link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” />.

    If its position is before the <link> for the random stylesheet, make it after then and vice versa.

    And make sure you have the files css1.css, css2.css and css3.css inside the theme directory.

    Thread Starter pookey

    (@pookey)

    I just removed <link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” / and it works!

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Need help with Stylesheet Url in WP!’ is closed to new replies.