Domanda

I am trying to link a new JavaScript file where I want to add some custom jQuery to the content. But it is not showing on my website or pages.

Here is the code in functions.php and my JavaScript file

function my_child_script(){
    wp_enqueue_script(
        'custom-child',
        get_stylesheet_directory_uri() . '/js/child-custom.js',
        array( 'jquery' ),
        '1.0.0',
        true
    );
}
add_action( 'wp_enqueue_script', 'my_child_script' );

and this is what am trying to do in my custom js file

jQuery(document).ready(function() {
    jQuery(".block-title-wrap").hide();
});
È stato utile?

Soluzione

Just replace your add action line to this one: add_action( 'wp_enqueue_scripts', 'my_child_script' ); and check again

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top