ThemeShaper Forums » Thematic


Adding facebook like button / social widgets next to post meta

(37 posts)
  • Started 12 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="' . 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="' . 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 11 years ago #
  2. Oki 2nd try:

    function custom_social_media_links() { ?>
    <div id="custom_social_media_links">
    Teile mit:
    <a href="<?php the_permalink(); ?>&t=<?php the_title(); ?>" title="Click to send this article to Facebook!" target="blank"><img src="" alt="Share this article on Facebook" /></a>
    <a href="<?php the_title(); ?> – <?php the_permalink(); ?>" title="Click to send this article to Twitter!" target="_blank"><img src="" alt="Share this article on Twitter" /></a>
    <?php } 
    function add_social_media_links_to_postfooter($footer) {
    $social_media_links = custom_social_media_links();
    $footer = $social_media_links . $footer;
    return $footer;
    function custom_face_youtube_links() { ?>
    <div align="center" id="custom_face_youtube_links">
    <a href="" title="Trete der Facebookgruppe bei!" target="blank"><img src="" alt="Trete der Facebookgruppe bei!" /></a>
    <a href="" title="Schau dir unseren YouTube Kanal an!" target="_blank"><img src="" 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="" alt="RSS Feed!" /></a>
    <?php } 
    function add_face_youtube_links_to_betweenmainasides($side) {
    $face_youtube_links = custom_face_youtube_links();
    $side = $face_youtube_links . $side;
    return $side;

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

    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 11 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 11 years ago #
  4. newb

    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 11 years ago #
  5. logostar

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

    Posted 11 years ago #
  6. logostar

    Never mind, I got it figured out.

    Posted 11 years ago #
  7. carrisi

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

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.