• Resolved solosails

    (@solosails)


    Hi,

    Having delved into the twitter card stuff for the first time the other day I have a request that I’m sure you’re planning on implementing anyway, but as a user I would like to say this would be very handy …

    Is there any way to have an option in a post (and more importantly a product) that allows to select the type of twitter card to be used? Ie summary (which is is fixed to now) or summary_large_image or product etc?

    This would be a very handy and simple thing to add and would make this function a lot more useful.

    Yesterday I altered your code a little to make it default as the summary_large_image rather than summary, which for me is a better option to have as standard, but this will obviously get wiped by the next update and to have a choice for different situations would be great anyway.

    Thanks very much in advance.

    Cheers.

    https://www.ads-software.com/plugins/all-in-one-seo-pack/

Viewing 15 replies - 1 through 15 (of 17 total)
  • 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;
    }
    Thread Starter solosails

    (@solosails)

    Hi Peter,

    Thanks for your reply and the code, I’ll give it a go!

    Look forward to the updated version.

    Thanks again, Andrew

    Thread Starter solosails

    (@solosails)

    Works a treat, thanks again.

    You’re welcome Andrew, always glad to hear that!

    Thread Starter solosails

    (@solosails)

    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;
    }
    Thread Starter solosails

    (@solosails)

    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.

    Thread Starter solosails

    (@solosails)

    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?

    Thread Starter solosails

    (@solosails)

    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

    Thread Starter solosails

    (@solosails)

    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=”https://your-site.com/streaming-file.mp4″&gt; for full functionality.

    Just hoped you might go, yeah, just add xxx in your functions php… perhaps!

    Thanks, Andrew

    Thread Starter solosails

    (@solosails)

    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

    Thread Starter solosails

    (@solosails)

    Perhaps, for now, is there a hack I can implement in the AIO SEO functions that will make the default into Summary Large Image?

    Thread Starter solosails

    (@solosails)

    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

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Twitter card function request’ is closed to new replies.