Social Share with PHP Logic - WordPress and Headway 3.0x


/ Published in: PHP
Save to your folder(s)

Display some custom social media icons after the post title on certain pages/posts in Headway 3.x and php conditional logic


Copy this code and paste it in your HTML
  1. <?php
  2. function posttopsocial() {
  3. // Let's put our code in a variable so we can use it more easily later
  4. $social = '<div id="posttopsocial"><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="davidgadarian">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><g:plusone size="medium"></g:plusone>
  5. <script src="http://www.stumbleupon.com/hostedbadge.php?s=1"></script><script src="http://connect.facebook.net/en_US/all.js#appId=192972320747968&xfbml=1"></script><fb:like href="" send="false" layout="button_count" width="90" show_faces="false" font="tahoma"></fb:like><script src="http://platform.linkedin.com/in.js" type="text/javascript"></script><script type="IN/Share" data-counter="right"></script></div>';
  6.  
  7. // Now let's test for our conditions and decide what to show
  8.  
  9. // Is it a single post? Is it the blog index?
  10. // is_home() tests for the WordPress blog index
  11. // The page in question has an ID of 868
  12. if (is_single() || is_home() || is_page('868')) {
  13. echo $social; // show our social stuff!
  14. } else {
  15. echo ''; // Don't echo anything, we don't want to show it
  16. }
  17. <?php }
  18. add_action('headway_after_entry_title','posttopsocial');
  19. ?>

URL: http://rentageekmom.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.