is_front_page not working
-
I am using a static site and I am trying to use is_front_page so that only styles/scripts that are needed on the home page get included there, however it’s not working; it’s not including them even though I am on the front page.
Here is my code from my themes functions.php file..
/* Load style files on the 'wp_enqueue_scripts' action hook. */ add_action( 'wp_enqueue_scripts', 'mmw_new_load_styles' ); /* Load script files on the 'wp_enqueue_scripts' action hook. */ add_action( 'wp_enqueue_scripts', 'mmw_new_load_scripts' ); function mmw_new_load_styles() { wp_enqueue_style( 'mmw-reset', get_template_directory_uri() . '/reset.css' ); wp_enqueue_style( 'mmw-style', get_bloginfo('stylesheet_url'), array('mmw-reset') ); if (is_front_page()) { wp_enqueue_style( 'mmw-rhino', get_template_directory_uri() . '/rhinoslider-1.05.css', array('mmw-reset','mmw-style') ); } wp_enqueue_style( 'mmw-ie8', get_template_directory_uri() . '/ie8.css', array('mmw-reset','mmw-style') ); wp_enqueue_style( 'mmw-ie7', get_template_directory_uri() . '/ie7.css', array('mmw-reset','mmw-style','mmw-ie8') ); // Apply IE conditionals $GLOBALS['wp_styles']->add_data( 'mmw-ie8', 'conditional', 'lte IE 8' ); $GLOBALS['wp_styles']->add_data( 'mmw-ie7', 'conditional', 'lte IE 7' ); } function mmw_new_load_scripts() { wp_enqueue_script('jquery'); if (is_front_page()) { wp_enqueue_script('rhino', get_template_directory_uri() . '/js/rhinoslider-1.05.min.js', array('jquery')); wp_enqueue_script('rhino-mw', get_template_directory_uri() . '/js/mousewheel.js', array('jquery','rhino')); wp_enqueue_script('rhino-easing', get_template_directory_uri() . '/js/easing.js', array('jquery','rhino','rhino-mw')); } wp_enqueue_script('scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery')); }I know this conditional tag can’t be used until the
posts_selectionhook has been fired, but since it’s been hooked to thewp_enqueue_scriptshook which fires after I don’t see why I am getting problems!?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘is_front_page not working’ is closed to new replies.