• Resolved garciasanchezdani

    (@garciasanchezdani)


    Hi all, I’m using it in a single post, like this:

    add_action( 'wp_enqueue_scripts', 'wp_add_unit_scripts' );
    function wp_add_unit_scripts() {
    
        global $post;
    
        wp_register_script('unit_more_widgets_scripts', WP_PLUGIN_DIR.'/js/funcionalidad.js', array( 'jquery' ));
    
        if($post->post_author == ID_USUARIO){
            wp_enqueue_script('unit_more_widgets_scripts');
        }
    }

    I’m calling it just after get_header … but I’m debugging and the code inside the function isn’t executed…

    What I try is to add some javascript in one single post, only if this post has been created by determined user…

    Thanks, Daniel

Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘wp enqueue scripts don't work’ is closed to new replies.