Title: Twitter card function request
Last modified: August 21, 2016

---

# Twitter card function request

 *  Resolved [solosails](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/)
 * 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://wordpress.org/plugins/all-in-one-seo-pack/](https://wordpress.org/plugins/all-in-one-seo-pack/)

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/twitter-card-function-request/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/twitter-card-function-request/page/2/?output_format=md)

 *  [Peter Baylies](https://wordpress.org/support/users/pbaylies/)
 * (@pbaylies)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853822)
 * 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](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853825)
 * 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](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853826)
 * Works a treat, thanks again.
 *  [Peter Baylies](https://wordpress.org/support/users/pbaylies/)
 * (@pbaylies)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853827)
 * You’re welcome Andrew, always glad to hear that!
 *  Thread Starter [solosails](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853828)
 * 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?
 *  [Peter Baylies](https://wordpress.org/support/users/pbaylies/)
 * (@pbaylies)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853829)
 * 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](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853830)
 * 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?
 *  [Peter Baylies](https://wordpress.org/support/users/pbaylies/)
 * (@pbaylies)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853831)
 * That’s strange; see if it does the same thing without the WooCommerce Twitter
   Card product plugin active.
 *  Thread Starter [solosails](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853832)
 * Nope, even with it deactivated, it doesn’t show the large image on an ordinary
   post?
 *  [Peter Baylies](https://wordpress.org/support/users/pbaylies/)
 * (@pbaylies)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853833)
 * 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](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853834)
 * 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](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [12 years ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853873)
 * 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″&gt](http://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](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853949)
 * 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](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853950)
 * 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](https://wordpress.org/support/users/solosails/)
 * (@solosails)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/twitter-card-function-request/#post-4853951)
 * 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)

1 [2](https://wordpress.org/support/topic/twitter-card-function-request/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/twitter-card-function-request/page/2/?output_format=md)

The topic ‘Twitter card function request’ is closed to new replies.

 * ![](https://ps.w.org/all-in-one-seo-pack/assets/icon.svg?rev=2443290)
 * [All in One SEO – Powerful SEO Plugin to Boost SEO Rankings & Increase Traffic](https://wordpress.org/plugins/all-in-one-seo-pack/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/all-in-one-seo-pack/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/all-in-one-seo-pack/)
 * [Active Topics](https://wordpress.org/support/plugin/all-in-one-seo-pack/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/all-in-one-seo-pack/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/all-in-one-seo-pack/reviews/)

## Tags

 * [twitter card](https://wordpress.org/support/topic-tag/twitter-card/)

 * 17 replies
 * 2 participants
 * Last reply from: [solosails](https://wordpress.org/support/users/solosails/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/twitter-card-function-request/page/2/#post-4853953)
 * Status: resolved