Calling 2 different stylesheets wordpress (some logic within)

Hi guys I have some logic here that does not seem to be working for me. Currently I am trying to use two different stylesheets in wordpress. Here is the logic:

        <?php 

$url = "$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if ($url=="theurl.com")
    {
        ?><link rel="stylesheet" type="text/css" href="stylesheetforthispage.css" /><?;
    }
    else
   {
        ?><link rel="stylesheet" type="text/css" href="stylesheetforotherpages.css" /><?;
    }

    ?>

My problem is that the URL that I am trying to use the other stylesheet for is the homepage, and everytime I try this logic is does not seem to work? All help would be appreciated, thanks in advance!

Solutions

<?php
    if ($_SERVER["REQUEST_URI"] == "/")
        echo '<link rel="stylesheet" href="/css/homepage.css" type="text/css"/>';
    else
        echo '<link rel="stylesheet" href="/css/other-pages.css" type="text/css"/>';
?>

Similar questions

WordPress: how enqueue two stylesheets for different pages
I am attempting to enqueue two stylesheets in Wordpress child theme. I have written front-page.php for which I wish to apply exclusively front-page-style.css. In addition, I have written header.php to override the parent theme's header. I have written style.css override the parent's stylesheet if it is in conflict. For neither front-page.php nor al...
wp_enqueue_script calling jQuery at different times for different browsers?
This makes no sense, but in looking at my view source across browsers, wp_localize_script() is inserting tags as expected for all browsers other than IE7,8,9. The script tag is simply not there in those browsers. I have it bound to "jquery", since I want to make sure it's included no matter what (rather than binding it to any specific user-defined ...
Calling WP_Query with the same args in two different places produces two different results
Given the following code: I would expect the produced request to look consistent regardless of where/when this code is invoked. Instead, I'm seeing it produce different results depending on where it is being invoked and it is unclear to me why this is the case given that the arguments do not change. Currently, one invocation exists on page load in ...
Enqueue different stylesheets using IE conditionals
I want to load a different css for IE 9 below so I have two files : - style.css - ie.css I used this code : and used this for IE but I dont know how to use this condition to use style.css for both non-IE and IE9
TinyMCE custom stylesheets for different post types
I use a custom stylesheet for TinyMCE, by placing custom styles in editor-style.css in my theme's directory. I am trying to figure out how to use a different stylesheet depending on what post type we are editing. One way of getting different styles in TinyMCE is to toggle a class in the TinyMCE iFrame's <body> tag. I have seen this in the New...
How can I assign separate stylesheets to different pages?
I am trying to figure out how to assign a seperate stylesheet for different pages? I wan't to use the same stylesheet for my front page, and page template and a different stylesheet for my blog and it's related pages. My theme only consists of a front page, a page template and a blog. So I would somehow need to figure out how to differentiate from ...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.