ThemeShaper Forums » Thematic

[closed]

comments_link, comments_number displaying before called

(2 posts)
  • Started 3 years ago by krackpot
  • Latest reply from krackpot
  • This topic is resolved
  1. krackpot
    Member

    I have a function which puts the comments link and comments number in a div in the postheader, but it is not being displayed correctly. The link and the number display before it is being called by the function?

    function childtheme_override_postheader_postmeta() {
    
    	$postmeta = '<div class="entry-meta">';
    	$postmeta .= thematic_postmeta_authorlink();
    	$postmeta .= thematic_postmeta_entrydate();
    
    	$postmeta .= '<div class="bubble"><p><a href="';
    	$postmeta .= comments_link();
    	$postmeta .= '">';
    	$postmeta .= comments_number('0','1','%');
    	$postmeta .= '</a></div>';
    
    	$postmeta .= thematic_postmeta_editlink();
    
    	$postmeta .= "</div><!-- .entry-meta -->\n";
    	return $postmeta;
    }
    add_filter('thematic_postheader_postmeta','childtheme_override_postheader_postmeta');

    Which results in the comment link and number of comments displayed as text before the post title.

    Somehow it is being displayed outside of where I want it.

    I followed this post: http://forums.themeshaper.com/topic/why-cant-i-post-a-topic#post-14322 , which seems related, but I don't know how to fix it?

    Does this mean I must rewrite each function to use return instead of echo for this purpose?

    Posted 3 years ago #
  2. krackpot
    Member

    I did a little digging in the footer area where the comments section by default is called from a normal thematic theme.

    The functions I used to call "comments_link()" and "comments_number()" are not the right ones, which describes why it was outputting before the post title.

    I should have used "get_permalink()" and "get_comments_number()" instead.

    I will provide the correct code for those who wish to use it:

    function childtheme_override_postheader_postmeta() {
    
    	$postmeta = '<div class="entry-meta">';
    	$postmeta .= thematic_postmeta_authorlink();
    	$postmeta .= thematic_postmeta_entrydate();
    
    	$postmeta .= '<div class="bubble"><a href="';
    	$postmeta .= get_permalink();
    	$postmeta .= '">';
    	$postmeta .= get_comments_number();
    	$postmeta .= '</a></div>';
    
    	$postmeta .= thematic_postmeta_editlink();
    
    	$postmeta .= "</div><!-- .entry-meta -->\n";
    	return $postmeta;
    }
    add_filter('thematic_postheader_postmeta','childtheme_override_postheader_postmeta');

    I might not have mentioned it, but this is what I was trying to achieve for this function: http://thomasgriffinmedia.com/blog/2010/10/how-to-add-a-comment-bubble-beside-your-headline-title-in-thesis/

    Hopefully someone will find this post useful. Problem solved! :)

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.