ThemeShaper Forums » Thematic


ShareThis in the thematic_postheader_postmeta issue

(6 posts)
  • Started 5 years ago by goboygodesign
  • Latest reply from initialsbr
  • This topic is resolved
  1. So I am having a strange issue - I added a custom function to append the sharethis buttons to the post-header meta and it puts it there without any problem, but it somehow also adds a random title and permalink above the post content as well and I can't figure out why it would do that. I'm using the latest version of the sharethis plugin with auto-add turned off and this code to add the buttons to my postheader:

    function my_sharefb() {
    	$postmeta = '<span class="st_facebook" st_title="' . the_title() . '" st_url="' . the_permalink() . '" ></span>';
    	return $postmeta;
    function my_sharetw() {
    	$postmeta = '<span class="st_twitter" st_title="' . the_title() . '" st_url="' . the_permalink() . '" ></span>';
    	return $postmeta;
    function my_shareem() {
    	 $postmeta = '<span class="st_email" st_title="' . the_title() . '" st_url="' . the_permalink() . '" ></span>';
    	 return $postmeta;
    function my_sharethis() {
    	$postmeta = '<span class="st_sharethis" st_title="' . the_title() . '" st_url="' . the_permalink() . '" ></span>';
    	return $postmeta;
    function my_postmeta() {
        $postmeta = '<div class="entry-meta">';
        $postmeta .= thematic_postmeta_authorlink();
        $postmeta .= '<span class="meta-sep meta-sep-entry-date"> | </span>';
        $postmeta .= thematic_postmeta_entrydate();
    	$postmeta .= ' <span class="meta-sep meta-sep-tweetmeme">|</span> ';
    	$postmeta .= my_sharefb();
    	$postmeta .= my_sharetw();
    	$postmeta .= my_shareem();
    	$postmeta .= my_sharethis();
    	$postmeta .= '</span>';
        $postmeta .= thematic_postmeta_editlink();
        $postmeta .= "</div><!-- .entry-meta -->\n";
        return $postmeta;
    add_filter('thematic_postheader_postmeta', 'my_postmeta');

    Take a look at the output:

    Any ideas?

    Posted 5 years ago #
  2. b/c the_title() and the_permalink() ECHO out their values by default... so they spit out titles and permalinks as soon as those functions are encountered. you need to RETURN values instead using

    get_the_title() and i think, get_permalink()

    also i can't think of a reason why you need to separate out the my_sharefb() function. just roll it into my_postmeta()

    Posted 5 years ago #
  3. Amazing! Thank you I've been racking my brain trying to figure that one out. The only reason I split all those functions off was to try to trace the issue (with no luck). Thanks!

    Posted 5 years ago #
  4. initialsbr

    I'm trying to do this same thing and was wondering what the final code looked like for you, goboygodesign. Thanks!

    Posted 4 years ago #
  5. it's the same code probably except following my advice to replace the_title() with get_the_title() and replacing the_permalink() with get_permalink()

    Posted 4 years ago #
  6. initialsbr

    Gotcha! That's what I thought you were saying, but I was stupidly trying "get_the_permalink" and it was breaking the site. Thanks helgatheviking!

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.