• [ Moderator note: moved to How-to and Troubleshooting. ]

    My create wp_enqueue_scripts functions. my create function not working.

    add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ );
    function theme_name_scripts() {
    wp_enqueue_style( ‘style’, get_template_directory_uri() . ‘/css/style.css’, array(), ”,’screen’ );
    wp_enqueue_style( ‘wide’, get_template_directory_uri() . ‘/css/layout/wide.css’, array(”), ”,’all’ );

    }

    How can i query same html bellow

    <link rel=”stylesheet” type=”text/css” href=”css/style.css” media=”screen” data-name=”skins”>
    <link rel=”stylesheet” href=”css/layout/wide.css” data-name=”layout”>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Your first stylesheet should be loading correctly. For your second stylesheet, you should remove the single quotes from within the array():

    wp_enqueue_style( 'wide', get_template_directory_uri() . '/css/layout/wide.css', array(), '','all' );

    Can you post a link to your site?

    Thread Starter Md. Shiddikur Rahman

    (@md-shiddikur-rahman)

    It’s for styleswitcher stylesheet. How to integrate data-name=”layout” / data-name=”skins” call wp_enqueue_style.

    Warning: This feels like a gross misuse of this particular filter, and this code isn’t exactly the most robust code out there. I highly recommend that you simply link the stylesheets in the header as you’ve been doing, unless it’s essential that you use wp_enqueue_style() for whatever reason. I’m going to assume that the use of data-name is required.

    Try this code in your functions.php, after your current code:

    function sc_add_script( $tag ) {
    	 if ( 0 !== ( strpos( $tag, 'style-css' ) ) ) {
    	 $tag = str_replace( 'style-css\'', 'style-css\' data-name="skins"', $tag );
    
    	 }
    
    	 if ( 0 !== ( strpos( $tag, 'wide-css' ) ) ) {
    	 $tag = str_replace( 'wide-css\'', 'wide-css\' data-name="layout"', $tag );
    
    	 }
    
    	 return $tag;
    }
    add_filter( 'style_loader_tag', 'sc_add_script' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to Call stylesheet wp_enqueue_style’ is closed to new replies.