Hi solosails,
Thanks for the suggestion, I’ll add it to the roadmap; you can currently do this with our hooks as well, here’s a code example:
add_filter( 'aiosp_opengraph_meta', 'solosails_filter_card', 10, 3 );
function solosails_filter_card( $value, $type, $field ) {
if ( ( $type == 'twitter' ) && ( $field == 'card' ) ) {
$value = 'summary_large_image';
}
return $value;
}
Hi Peter,
Thanks for your reply and the code, I’ll give it a go!
Look forward to the updated version.
Thanks again, Andrew
Works a treat, thanks again.
You’re welcome Andrew, always glad to hear that!
Ah, actually, I found an issue using this, it not your plugin though.
Today, I installed woocommerce twitter card product plugin which changes your titter card meta to product on the product pages. This worked fine, but now I use your hook, it doesn’t do this any more?
Any ideas?
Hi Andrew,
I don’t know how they go about changing it, but one solution would be to check for their product pages in this function and not change the value in that case (or change it to product in this code as well).
function solosails_filter_card( $value, $type, $field ) {
if ( ( $type == 'twitter' ) && ( $field == 'card' ) ) {
if ( ( function_exists( 'is_product' ) ) && ( is_product() ) ) {
$value = 'product';
} else {
$value = 'summary_large_image';
}
}
return $value;
}
hmm, works correctly in product pages, but the ‘else summary_large_image’ doesn’t seem to appear in the other pages, just stays as summary?
That’s strange; see if it does the same thing without the WooCommerce Twitter Card product plugin active.
Nope, even with it deactivated, it doesn’t show the large image on an ordinary post?
But is it outputting summary_large_image for the Twitter card meta? I trust you didn’t get rid of the add_filter() line?
oops,,, yes I did delete it!
I can confirm that your code works perfectly now, thank you very very much for your time, Andrew
This works fine..
add_filter( 'aiosp_opengraph_meta', 'solosails_filter_card', 10, 3 );
function solosails_filter_card( $value, $type, $field ) {
if ( ( $type == 'twitter' ) && ( $field == 'card' ) ) {
if ( ( function_exists( 'is_product' ) ) && ( is_product() ) ) {
$value = 'product';
} else {
$value = 'summary_large_image';
}
}
return $value;
}
For anyone reading this, the plugin I am using in conjunction is Twitter Product Card for WooCommerce
Hi again Peter,
This is just pushing my luck a bit… well a lot actually!
Any ideas how I might get AIOSEOP to add the ‘player’ twitter card into posts?
It requires
<meta name=”twitter:card” content=”player”> as a minimum and
<meta name=”twitter:player:stream” content=”http://your-site.com/streaming-file.mp4″> for full functionality.
Just hoped you might go, yeah, just add xxx in your functions php… perhaps!
Thanks, Andrew
Hey Peter,
Thanks ever so much for the recent release of AIO SEO that includes the Twitter Card Meta options.
Is there any chance in the next release you could put an option in the AIO SEO settings to choose what the default is?
I pretty much always want to use the ‘Summary Large Image’ , but currently it defaults to ‘Summary’ which is fine, but means I have to remember every time to change that setting.
Many thanks for all your help again, Andrew
Perhaps, for now, is there a hack I can implement in the AIO SEO functions that will make the default into Summary Large Image?
Hi,
My apologies, you have done this already, sorry I missed that the first time I looked in the settings!
Great work, thanks again!
Cheers, Andrew