0
votes

I'm having trouble troubleshooting a new client site.

I'm using CSS media queries but for some reason modernizr/respond.js is not working for IE7 & 8 – I've been looking over this all morning and cannot fix it. Wondered if a fresh pair of eyes could spot anything I can't...?

Site is here: http://cy4or.co.uk

UPDATE: I'm wondering if this has anything to do with Parent/Child themes in Wordpress. Previously this site used one theme, I since split that theme into a parent and child theme and (I think) that's when the problem began.

UPDATE 2: It DEFINITELY has something to do with parent / child themes. activated just the parent them and all works fine.

3

3 Answers

1
votes

I too was suffering from Respond.js not parsing the media queries in my WordPress parent/child theme configuration which involves using @import in the child CSS file to pull in the parent theme CSS. I then discovered that according to the Respond.js documentation:

Respond.js doesn't parse CSS referenced via @import, nor does it work with media queries within style elements, as those styles can't be re-requested for parsing.

Since I am using Sass, the solution in my case was to @import the Sass file, not the CSS file:

@import '../parent/scss/style.scss';

This compiles the parent CSS into a single style.css file in the child theme and Respond.js renders the media queries as expected. If you were not using a preprocessor or had another reason to load the parent CSS file itself, this could be done with wp_enqueue_style.

function link_parent_theme_style() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style', get_stylesheet_uri() );
}
add_action('wp_enqueue_scripts', 'link_parent_theme_style'); 

Technically, this question should read "Respond.js not working with WordPress parent/child theme"

0
votes

Your page does not validate, and JavaScript will most likely need a correctly validating page to stand the best chance of executing without errors.

0
votes

So it turns out this problem was a bit of a tricky one to resolve.

I'm using .less to compile my css but for some reason when doing so with the Child theme and importing the parents css at the top of style.css it wasn't working in ie8 & below.

I wish I could expand on 'it wasn't working' but after 2 days of trouble shooting I really couldn't tell you what the problem was.

In the end I resorted to adding the child css directly to the header, followed by the parents css:

<link rel="stylesheet" href="http://site.com/wp-content/themes/Parent/style.css">
<link rel="stylesheet" href="http://site.com/wp-content/themes/Child/style.css">

This worked for me, I know it's not ideal but I can live with it. If anyone has any knowledge on working with .less app to compile child themes and parent themes css successfully I'd like to know.