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.]
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;
}
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…
You can add both pieces of code to your theme’s functions.php
file. Change the creator fields of course.
Ok thanks…now i’ve done that…do i now need to add those meta tags in my header file?
as long as your theme calls wp_head()
and the plugin is activated you should be all set.
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…
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 🙂
added filter howto in FAQ