Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter bigboybifdick

    (@bigboybifdick)

    add_action('wp_enqueue_scripts', 'my-css');

    doesn’t fire the function at all as i can’t even see my echo “Test”;

    :/

    Thread Starter bigboybifdick

    (@bigboybifdick)

    Hey,

    Thanks again man, but im’ not sure you’re getting what’s my problem here.
    The code you sent me is exactly the same i already have :

    add_action( 'wp_enqueue_scripts', 'my_css_method' );
    
    function my_css_method() {
    	wp_enqueue_style('test-style',get_template_directory_uri().'/demo.css');
    
    }

    I know that “wp_enqueue_scripts” only loads on front and “admin_enqueue_scripts” loads in backend 🙂

    My problem is that the css file loads fine when i use admin_enqueue (on the admin side of course), but it does not load on the front when i use wp_enqueue. My css file (demo.css) contains a {background-color:red} so i can know if it works or not, and it doesn’t in the front.

    So :

    The admin background is red if i use admin_enqueue (and i can see the file on the source code), but it’s not on the fnort side if i use wp_enqueue (and i don’t the file in the source).

    I also added an echo “test”, on both of my tests (front and admin enqueue), i can see it in the admin, not in the front.

    So it seems that the wp_enqueue_scripts doesn’t work for me… :/

    Here is my full functions.php file :

    <?php
    ////
    // SOME MENU STUFF
    ////
    add_action( 'init', 'register_my_menus' );
    function register_my_menus() {
      register_nav_menus(
        array(
          'header-menu' => __( 'Header Menu' ),
          'extra-menu' => __( 'Extra Menu' )
        )
      );
    }
    
    function add_menuclass($ulclass) {
       return preg_replace('/<a /', '<a class="pageload-link"', $ulclass);
    }
    add_filter('wp_nav_menu','add_menuclass');
    
    ////
    // ENQUEUE SCRIPTS PART
    ////
    add_action( 'wp_enqueue_scripts', 'my_css_method' );
    
    function my_css_method() {
    	wp_enqueue_style('test-style',get_template_directory_uri().'/demo.css');
    
    }
    
    ?>

    Could anyone help me ?

    Thanks a lot,

    Thread Starter bigboybifdick

    (@bigboybifdick)

    Hey,

    Thanks for answering. Sorry i was a bit confused, i tried a lot of things (desperado mooode) and i paste the bad code.

    It still wont work like this :

    // Here i can use _scripts, i read it was the same
    add_action( 'wp_enqueue_scripts', 'my_css_method' );
    
    function my_css_method() {
    // i corrected and replaced _script by _style
    wp_enqueue_style('my_stylesheet_unique_name',get_template_directory_uri() . "/demo.css", __FILE__);
    
    }

    The weird thing tough, is that the css is loaded in the admin if i replace

    add_action( 'wp_enqueue_scripts', 'my_css_method' );
    //by
    add_action( 'admin_enqueue_scripts', 'my_css_method' );

    So wp_enqueue_scripts is not working… Any idea why ?

    Thanks a lot,

Viewing 3 replies - 1 through 3 (of 3 total)