Advertisement:

Author Topic: Adding Twitter Summary Cards To Ads..  (Read 586 times)

DVyneDesign

  • Newbie
  • *
  • Posts: 7
Adding Twitter Summary Cards To Ads..
« on: May 09, 2017, 07:29:50 am »
So I decided to add Twitter summary cards to ads for those that decide to share them..  :D

Here's how I did it with OSC 3.7.3 and the latest Wizzards theme..

I'm sure it would work similar with bender..

Edit item.php in the template..

Find this line.. somewhere around line 95..
Code: [Select]
<div class="col-md-10"> <a href="<?php echo osc_resource_url(); ?>" class="main-photo" title="<?php echo osc_esc_html(__('Image'OSCLASSWIZARDS_THEME_FOLDER)); ?> <?php echo $i+1;?> / <?php echo osc_count_item_resources();?>"> <img class="img-responsive" src="<?php echo osc_resource_url();?>" alt="<?php echo osc_item_title(); ?>" title="<?php echo osc_item_title(); ?>" /> </a></div>

Change it to this.. (change is in bold)
<div class="col-md-10"> <a href="<?php echo osc_resource_url(); ?>" class="main-photo" title="<?php echo osc_esc_html(__('Image', OSCLASSWIZARDS_THEME_FOLDER)); ?> <?php echo $i+1;?> / <?php echo osc_count_item_resources();?>"> <img class="img-responsive" src="<?php echo osc_resource_url();$twitter_image = osc_resource_url();?>" alt="<?php echo osc_item_title(); ?>" title="<?php echo osc_item_title(); ?>" /> </a></div>

Immediately after that div insert these meta tags..
Code: [Select]
          <meta name="twitter:card" content="summary" />
          <meta name="twitter:site" content="@twitterusername" />
          <meta name="twitter:title" content="Put snappy title here!" />
          <meta name="twitter:description" content="<?php echo osc_item_title(); ?>" />
          <meta name="twitter:image" content="<?php echo ($twitter_image); ?>" />

You can also put the title call in the title meta tag and then put the osc_item_description(); in the discription.  My ads have very long titles with lots of special characters so I did it this way..

Then you can test it here.. http://cards-dev.twitter.com/validator

You need a valid & verified twitter account to use summary cards..

Hope this is useful for someone..  :)
« Last Edit: May 09, 2017, 08:02:44 am by DVyneDesign »