ThemeShaper Forums » Thematic

[closed]

Adding facebook like button / social widgets next to post meta

(37 posts)
  • Started 3 years ago by mcdermos20
  • Latest reply from carrisi
  • This topic is not resolved
  1. I've noticed code getting mangled when I've tried to copy and paste too. I hope this works.

    This is a little section from function my_postfooter(). Please note that it's not super-pretty because I have a load of no-breaking spaces. I use css background sprites (using a custom span class) instead of normal image links. See what I mean here. (I have since learned there is a cleaner way to do this.)

    Please also note that the code I found on that website doesn't validate. Replace the ampersand and em-dash with the html code. Actually, before I did this, it broke my entire site layout in IE.

    $postfooter .= '<span class="icon-twitter"><a href="http://twitter.com/home?status=' . get_the_title() . '-' . apply_filters('the_permalink', get_permalink()) . '" title="share on twitter" target="_blank">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></span>';
               $postfooter .= '<span class="meta-sep">&nbsp;&nbsp;&nbsp;</span>' ;
               $postfooter .= '<span class="icon-fb"><a href="http://www.facebook.com/sharer.php?u=' . apply_filters('the_permalink', get_permalink()) . '&amp;t='  . get_the_title() . '" title="share on facebook" target="blank">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></span>' ;
    Posted 3 years ago #
  2. Oki 2nd try:

    <code>
    function custom_social_media_links() { ?>
    <div id="custom_social_media_links">
    Teile mit:
    <a href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>" title="Click to send this article to Facebook!" target="blank"><img src="http://mariosta.ch/bilder/icons/facebook_32.png" alt="Share this article on Facebook" /></a>
    <a href="http://twitter.com/home?status=<?php the_title(); ?> – <?php the_permalink(); ?>" title="Click to send this article to Twitter!" target="_blank"><img src="http://mariosta.ch/bilder/icons/twitter_32.png" alt="Share this article on Twitter" /></a>
    </div>
    <?php } 
    
    function add_social_media_links_to_postfooter($footer) {
    $social_media_links = custom_social_media_links();
    $footer = $social_media_links . $footer;
    return $footer;
    } 
    
    add_action('thematic_postfooter','add_social_media_links_to_postfooter');
    
    function custom_face_youtube_links() { ?>
    <div align="center" id="custom_face_youtube_links">
    <a href="http://www.facebook.com/group.php?gid=352037097808" title="Trete der Facebookgruppe bei!" target="blank"><img src="http://mariosta.ch/bilder/icons/facebook_64.png" alt="Trete der Facebookgruppe bei!" /></a>
    <a href="http://www.youtube.com/user/lakaraviro" title="Schau dir unseren YouTube Kanal an!" target="_blank"><img src="http://mariosta.ch/bilder/icons/youtubex64.png" alt="Schau dir unseren YouTube Kanal an!" /></a>
    <a href="<?php bloginfo('rss2_url') ?>" title="<?php echo wp_specialchars(get_bloginfo('name'), 1) ?> <?php _e('Posts RSS feed', 'thematic'); ?>" rel="alternate nofollow" type="application/rss+xml"><img src="http://mariosta.ch/bilder/icons/rss_64.png" alt="RSS Feed!" /></a>
    <p>&nbsp;</p>
    </div>
    <?php } 
    
    function add_face_youtube_links_to_betweenmainasides($side) {
    $face_youtube_links = custom_face_youtube_links();
    $side = $face_youtube_links . $side;
    return $side;
    } 
    
    add_action('thematic_betweenmainasides','add_face_youtube_links_to_betweenmainasides');
    </code>

    @helgatheviking:
    Thanks :) i like your Site too, hehe and also the subject of fitness.

    @Jonny:
    I'm a Noob so, i don't know :) how efficient my way is.

    I have a Noob question, about this Code above, since i am working with Copy&Paste method:
    I don't understand what is the purpose of the second Part of the Function, there where you write the second time Function and end it with Return. And why you are creating something like "$xxx"?

    have a nice day!

    Posted 3 years ago #
  3. thanks! the weight training site is mostly defunct, though i wish i would revive it, but i've gotten so busy w/ theme development.

    your code will come in handy and save me having to look it up myself. to answer your newb question- that is just how filters work. in WP and in thematic there are spots that say apply_filters('filter_name',$variable); basically you return a value and that variable changes the value of the variable before the function is run. i hope that makes sense... had a little whiskey earlier.

    Posted 3 years ago #
  4. newb
    Member

    Hi Jonny,

    I'm using addthis and want to insert it to postfooter meta. Using your code gave me good results except one problem - all icons are at the next line after meta. How to add it to the same line?

    Posted 2 years ago #
  5. logostar
    Member

    Already have social media links written up in html, how do one put this in header file before the main content start?

    Posted 2 years ago #
  6. logostar
    Member

    Never mind, I got it figured out.

    Posted 2 years ago #
  7. carrisi
    Member

    great bit of code from Karaviro but i dont seem to be able to chnge the image link?

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.