Support » Plugin: Yoast SEO » Change Twitter Card type

  • Resolved Ricard Torres


    Hey guys,

    Does anyone know what filter/hook thing should I add to my functions.php file to change the Twitter Card type?

    Within the plugin you can find this:

    This defaults to summary but can be filtered using the wpseo_twitter_card_type filter.

    * Display the Twitter card type.
     * This defaults to summary but can be filtered using the <code>wpseo_twitter_card_type</code> filter.
    public function type() {
    	echo '<meta name="twitter:card" content="' . apply_filters( 'wpseo_twitter_card_type', 'summary' ) . '"/>' . "\n";

    Any idea?

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Found it, here’s the solution:

    add_filter( 'wpseo_twitter_card_type', 'change_card_type', 20 );
    function change_card_type(  ) {
    	return 'summary_large_image';

    You can easily change card type. above is suggested method but there is another method.

    Goto Plugins->Installed Plugin->WordPress SEO-> and Click on Edit option under WordPress SEO. Look for class-twitter.php under Plugin Files.

    Hit Control+F on Chrome and enter summary on Box. It will highlight all words with summary keyword. Change Summary with summary_large_image or any other card type as given in code below. Hit save and apply for selected card. This method is not recommended but it is good for programmers…and coders.

    public function type() {
    		$type = apply_filters( 'wpseo_twitter_card_type', 'summary_large_image' );
    		if( !in_array( $type, array(  'summary_large_image', 'summary', 'photo', 'gallery', 'app', 'player', 'product' ) ) )
    			$type = 'summary_large_image';

    You should never edit a plugin’s code! With your suggestion you can not update the plugin anymore, if you do, you lose the changes.

    Follow my snippet and paste it within your functions.php file!


    Thanks Rick, great help!

    I have seen that in the latest Yoast SEO plugin version you can choose between Standard and Standard Large Image. I wonder why the other card twitter cards are not (yet?) available from the drop-down menu

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change Twitter Card type’ is closed to new replies.