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="" class="twitter-share-button" data-count="horizontal" data-via="davidgadarian">Tweet</a><script type="text/javascript" src=""></script><g:plusone size="medium"></g:plusone>
  5. <script src=""></script><script src=""></script><fb:like href="" send="false" layout="button_count" width="90" show_faces="false" font="tahoma"></fb:like><script src="" type="text/javascript"></script><script type="IN/Share" data-counter="right"></script></div>';
  7. // Now let's test for our conditions and decide what to show
  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. ?>


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.