With the updates in my patch, here’s how I integrated the plugin in our site so that our logo shows up on non single pages and so that our twitter account is linked in:
// Twitter cards
// Display cards on every page instead of only single.
function tribe_twitter_cards_display() {
return true;
}
add_filter( 'twitter_cards_display', 'tribe_twitter_cards_display' );
// Filter twitter URL. (not really using this... it can be deleted)
function tribe_twitter_cards_url( $url ) {
return $url;
}
add_filter( 'twitter_cards_url', 'tribe_twitter_cards_url' );
// Filter twitter title.
function tribe_twitter_cards_title( $title ) {
if ( !is_single() && !is_tax() ) {
// If this is not singel and not a category, use the blog title.
$title = get_bloginfo('name', 'display');
}
return $title;
}
add_filter( 'twitter_cards_title', 'tribe_twitter_cards_title' );
// Filter twitter description.
function tribe_twitter_cards_description( $description ) {
if ( !is_single() ) {
// if this is not single, use the site description
$description = get_bloginfo('description', 'display');
}
return $description;
}
add_filter( 'twitter_cards_description', 'tribe_twitter_cards_description' );
// Filter twitter thumbnail.
function tribe_twitter_cards_thumbnail( $thumb ) {
if ( !is_single() || empty($thumb) ) {
// If this is not single and doesn't have a thumb, then use a hardcoded logo.
$thumb = array(
'url' => get_bloginfo ( 'template_directory' ) . '/images/branding/facebook.png',
'width' => 114,
'height' => 114
);
}
return $thumb;
}
add_filter( 'twitter_cards_thumbnail', 'tribe_twitter_cards_thumbnail' );
// Filter twitter account.
function tribe_twitter_cards_site( $site ) {
return '@moderntribeinc';
}
add_filter( 'twitter_cards_site', 'tribe_twitter_cards_site' );