• Insect Trojan

    (@insecttrojan)


    add_action( 'wp_enqueue_scripts', function() {
        // Your conditional goes here. For example:
        // Allow only on single posts (of any post type)
        if ( is_singular('post') ) return;
    
        // Remove AddToAny core script.
        // Note: This disables AddToAny's ability to load dynamically.
        add_filter( 'addtoany_script_disabled', '__return_true' );
    
        // Remove AddToAny plugin's JS & CSS.
        wp_dequeue_script( 'addtoany' );
        wp_dequeue_style( 'addtoany' );
    }, 21);

    so in the if ( is_singular(‘post’) ) return; do i need
    if ( ! is_singular(‘post’) ) {
    return true;

    ? something is wrong on my code can you help me please ? thanks

    add_action( 'wp_enqueue_scripts', function() {
        // Your conditional goes here. For example:
        // Allow only on single posts (of any post type)
        if ( is_singular( 'post' ) ) {
    		return true;
    	}
    
        // Remove AddToAny core script.
        // Note: This disables AddToAny's ability to load dynamically.
    	add_filter( 'addtoany_script_disabled', '__return_true' );
    
        // Remove AddToAny plugin's JS & CSS.
    	wp_dequeue_script( 'addtoany' );
    	wp_dequeue_style( 'addtoany' );
    }, 21);

    The page I need help with: [log in to see the link]

  • The topic ‘run plugin only on posts’ is closed to new replies.