WordPress.org

Ready to get started?Download WordPress

Forums

Modernizr - Add class to element (3 posts)

  1. timrutter
    Member
    Posted 3 years ago #

    I need to be able to add the class 'no-js' to the 'html' element, hopefully using a simple filter or option in the functions.php file or the like.

    Basically I would prefer not to edit the template files.

    currently I am using the following in the functions file with thematic.

    function childtheme_create_doctype($content) {
    	$content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
    	$content .= '<html xmlns="http://www.w3.org/1999/xhtml" class="no-js"';
    	return $content;
    }
    add_filter('thematic_create_doctype', 'childtheme_create_doctype');
  2. Connor Montgomery
    Member
    Posted 3 years ago #

    The only way to add something to a template is to edit a template file... ;)

    But on a more serious note - what's the URL for your site? Is that function not working? I see you created/edited that function, but are you including it in all of your pages so it dynamically creates the header?

  3. Ramoonus
    Member
    Posted 3 years ago #

    I`ve released a plugin to make this easier
    http://wordpress.org/extend/plugins/modernizr/

Topic Closed

This topic has been closed to new replies.

About this Topic