• Resolved savvi

    (@savvi)


    Hi I know we have the ability to turn social elements on or off but I need to turn them off only for a specific custom post type.

    I’ve had a google and look around on the web but none of the stackoverflow answers work. Would be great if yoast had the same control for social that it does for the regular meta data. But in mean time if anyone knows a line or two of code I can drop in to make this work I’d be very grateful.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Md Mazedul Islam Khan

    (@mazedulislamkhan)

    In order to disable Twitter card on certain post types, you’ll need to use the wpseo_output_twitter_card filter conditionally. For your convenience, we have listed the following example:

    if ( is_singular( 'book' ) ) {
        add_filter( 'wpseo_output_twitter_card', '__return_false' );
    }
    

    Where book would be the name of your custom post types. The above is true when viewing a post of the custom post type: book.

    Notice that it is not guaranteed that the above code will work. You may need to tweak this based on your setup and your needs. It is recommended to take a backup before applying the custom code.

    Thread Starter savvi

    (@savvi)

    thank you.

    Is there a catch all for the opengraph tags as well?

    “wpseo_output_opengraph” didn’t work so is there one or do i have to specify each tag I want to turn off.

    devnihil

    (@devnihil)

    @savvi If you want to disable all Open Graph output for a single page, you can find example code for doing this here.

    Thread Starter savvi

    (@savvi)

    non of these seem to work for me

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

The topic ‘Stop Yoast adding Twitter on custom posts’ is closed to new replies.