/ Published in: PHP
Display some custom social media icons after the post title on certain pages/posts in Headway 3.x and php conditional logic
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function posttopsocial() { // Let's put our code in a variable so we can use it more easily later $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> <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>'; // Now let's test for our conditions and decide what to show // Is it a single post? Is it the blog index? // is_home() tests for the WordPress blog index // The page in question has an ID of 868 if (is_single() || is_home() || is_page('868')) { echo $social; // show our social stuff! } else { echo ''; // Don't echo anything, we don't want to show it } <?php } add_action('headway_after_entry_title','posttopsocial'); ?>