Linda Nagata: the blog at Hahví.net


A Problem with WordPress theme “Twenty Eleven” version 2.4

Saturday, April 23rd, 2016

Edit: WordPress pushed through an update today — April 26, 2016 — that fixed the issue described below.

I’m posting this in case it’s helpful to anyone out there who runs into the same problem I did.

My online bookstore is based on the WordPress theme “Twenty Eleven,” modified with a custom child theme. After updating to theme version 2.4, the child stylesheet was loading only on the front page. None of the styles from the child theme were being parsed on single posts or on pages. Also, the styles directly included in the header were not being parsed.

After much poking around, I finally narrowed down the issue. The child stylesheet was failing to load when the body tag included the class “singular”. I looked at the parent stylesheet, but could not find any obvious error that would cause this to happen. In the end, I simply eliminated the class from the body tag. So far I have not noticed any negative effect on the website–YMMV.

To eliminate the class, I included the code shown below in the custom function file in the child theme. The function is from the WordPress Codex. This is a hack, and it’s meant only for a very specific situation. Use at your own risk:


// Removes a class from the body_class array
add_filter( 'body_class', 'remove_class' );
function remove_class( $classes ) {
// search the array for the class to remove
$unset_key = array_search('singular', $classes);
if ( false !== $unset_key ) {
// unsets the class if the key exists
unset( $classes[$unset_key] );
}

// return the $classes array
return $classes;
}