WordPress.org

Forums

Twitter Cards
[resolved] How to set up Twitter-Cards Plug-in to my Twitter? (10 posts)

  1. Zweischneid
    Member
    Posted 2 years ago #

    Specify user twitter account/site ID?

    Where and how do I set the settings for my twitter account/site ID?

    Description says twitter_properties_filter which I assume is this?

    $t = apply_filters( 'twitter_cards_properties', $this->toArray() );
    		if ( ! is_array( $t ) || empty( $t ) )
    			return '';
    		$s = '';
    		foreach ( $t as $name => $value ) {
    			$s .= self::build_meta_element( $name, $value, $xml );
    		}
    		return $s;
    	}

    But where goes the twitter ID / User name?

    Also, where can I switch the meta properties for the entire card from summary to photo or video?

    Thanks

    Z.

    http://wordpress.org/extend/plugins/twitter-cards/

  2. aaltoni
    Member
    Posted 2 years ago #

    hmmm i can't find this filter properties anywhere? can you tell me where to find this code?

    $t = apply_filters( 'twitter_cards_properties', $this->toArray() );
    		if ( ! is_array( $t ) || empty( $t ) )
    			return '';
    		$s = '';
    		foreach ( $t as $name => $value ) {
    			$s .= self::build_meta_element( $name, $value, $xml );
    		}
    		return $s;
    	}

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser.]

  3. Niall Kennedy
    Member
    Plugin Author

    Posted 2 years ago #

    First you need to hook into the filter from code in your theme or site plugin(s).

    add_filter( 'twitter_cards_properties', 'twitter_custom' );

    Next you need to modify the array passed to the filter with your own values.

    function twitter_custom( $twitter_card ) {
    	if ( is_array( $twitter_card ) ) {
    		$twitter_card['creator'] = '@niall';
    		$twitter_card['creator:id'] = '1085';
    	}
    	return $twitter_card;
    }
  4. aaltoni
    Member
    Posted 2 years ago #

    Do i need to put this
    add_filter( 'twitter_cards_properties', 'twitter_custom' );

    in header or?

    and where i put this

    function twitter_custom( $twitter_card ) {
    if ( is_array( $twitter_card ) ) {
    $twitter_card['creator'] = '@niall';
    $twitter_card['creator:id'] = '1085';
    }
    return $twitter_card;
    }

    Sorry for being such a noob...

  5. Niall Kennedy
    Member
    Plugin Author

    Posted 2 years ago #

    You can add both pieces of code to your theme's functions.php file. Change the creator fields of course.

  6. aaltoni
    Member
    Posted 2 years ago #

    Ok thanks...now i've done that...do i now need to add those meta tags in my header file?

  7. Niall Kennedy
    Member
    Plugin Author

    Posted 2 years ago #

    as long as your theme calls wp_head() and the plugin is activated you should be all set.

  8. aaltoni
    Member
    Posted 2 years ago #

    plugin is activated, but not see Twitter cards anyway...hmmm i think im doing something wrong...I haven't include meta tags to my header file, but nothing changes anyway...gosh im noob...

  9. rrhobbs
    Member
    Posted 2 years ago #

    Niall - Adding the function into my child theme works for me - thx.

    Even if you dont have time to code into the the plugin so it is "plug n play", it would be very helpful to MANY people if you put the instructions in the installation tab.

    Thanks for your hard work :)

  10. Niall Kennedy
    Member
    Plugin Author

    Posted 2 years ago #

    added filter howto in FAQ

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Twitter Cards
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic