• Resolved vincentavct

    (@vincentavct)


    I registered a storefront child theme. From function.php I add class with require if is_admin ().
    I am looking to load a js script with wp_enqueue_scripts. in the constructor of my class

    add_action ('wp_enqueue_scripts', array ($ this, 'add_books_author_js'));

    my function

    public function add_books_author_js () {
    wp_deregister_script ('books-author-js');
    wp_register_script (
    'books-author-js',
    get_stylesheet_directory_uri (). '/assets/js/books-author.js',
    array ('jquery', 'jquery-ui-autocomplete'),
    '1.0',
    false
    );
    wp_enqueue_script ('books-author-js');
    } 

    it doesn’t work and if I copy the code into the class class-storefront-admin.php it works fine

    • This topic was modified 3 years, 1 month ago by vincentavct.
Viewing 1 replies (of 1 total)
  • Thread Starter vincentavct

    (@vincentavct)

    here is the solution to my question.

    add_action( 'admin_enqueue_scripts', array( $this, 'add_books_author_js' ) );

    indeed the script is called admin side

    • This reply was modified 3 years, 1 month ago by vincentavct.
Viewing 1 replies (of 1 total)
  • The topic ‘storefront theme child and wp_enqueue_scripts’ is closed to new replies.