WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] _s Underscores theme conditional stylesheet (3 posts)

  1. beckyddesign
    Member
    Posted 1 year ago #

    I have a site built with the Underscores theme where there are 2 background images. IE8 and below don't like this, so I've added a conditional stylesheet. Despite having done this on other sites, I cannot get this one to read properly. This theme's regular stylesheet is enqueued in the functions file. I have tried adding it the conventional way in the header:

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/ie.css "media="screen" type="text/css"/>
    <![endif]-->

    The path shows up correctly, but I don's see any of the style changes taking effect.

    I've also tried to enqueue it in the functions file:

    {
        global $wp_styles;
        // other style sheets...
        // ie-only style sheets
        wp_register_style('ie', get_bloginfo('template_directory') . '/ie.css');
        $wp_styles->add_data('ie', 'conditional', 'lte IE 8');
        wp_enqueue_style('ie');
    }

    This pulls a stylesheet in the wp-admin folder! Not what I'm looking for either. I feel like I'm missing something simple. Any help appreciated!

  2. paulwpxp
    Font hero
    Posted 1 year ago #

    Use get_stylesheet_directory() instead, it'll work regardless if in child or parent.

    Use if ( ! is_admin() ) to use it in web front only.

  3. beckyddesign
    Member
    Posted 1 year ago #

    Thanks Paul, but using stylesheet vs. template made no difference in either case.

    I believe the background image/IE8 issue may be a javascript conflict. By removing the declaration for it in the ie stylesheet altogether and adding !important to the other font size change declarations, I got it to work, so my original code in the header was correct.

    At least at this point I have something that works in IE8 and doesn't look horrible.

Topic Closed

This topic has been closed to new replies.

About this Topic