WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_enqueue_scripts for stylesheets not working (3 posts)

  1. creariz
    Member
    Posted 2 years ago #

    I´ve been reading a lot to try to solve this problem, and right now I really don´t know what´s wrong.

    I have the following code inside my functions.php and it doesn´t work. It causes the webpage not to load. If I delete it the webpage works perfectly.

    function add_my_stylesheets() {
    	if(!is_login() && !is_admin()) {
    		wp_register_style(style-general', get_stylesheet_directory_uri() . '/includes/css/style-general.css');
    		wp_register_style(style-ltie9', get_stylesheet_directory_uri() . '/includes/css/style-ltie9.css');
    		wp_register_style(style-ltie8', get_stylesheet_directory_uri() . '/includes/css/style-ltie8.css');
    		$GLOBALS['wp_styles']->add_data( style-ltie9', 'conditional', 'lt IE 9' );
    		$GLOBALS['wp_styles']->add_data( style-ltie8', 'conditional', 'lt IE 8' );
    		wp_enqueue_style(style-general');
    		wp_enqueue_style(style-ltie9');
    		wp_enqueue_style(style-ltie8');
    	}
    }
    add_action('wp_enqueue_scripts','add_my_stylesheets');

    I would appreciate some help.

  2. James Edmonston
    Member
    Posted 2 years ago #

    Have you tried echoing anything inside the if statement to check that it's actually working?

  3. creariz
    Member
    Posted 2 years ago #

    Thank you James. That was the actual solution to the problem. I really didn´t need the condition, cause wp_enqueue_scripts doesn´t run on admin pages or the login. Everything is working now.

Topic Closed

This topic has been closed to new replies.

About this Topic