Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've created a custom content.php and removed any comments on the content.php page

then i changed the sharing-service.php from jetpack and added comments_popup_link there:

// Wrapper
$sharing_content .= '<div class="sharedaddy sd-sharing-enabled">';
$sharing_content .= '<div class="robots-nocontent sd-block sd-social sd-social-' . $global['button_style'] . ' sd-sharing">';

if ( $global['sharing_label'] != '' )
    $sharing_content .= '<h3 class="sd-title">'. comments_popup_link(  __( 'Leave a reply', 'changed2012' ) , __( '1 Reply', 'changed2012' ), __( '% Replies', 'changed2012' ) ) . $global['sharing_label'] . '</h3>';
$sharing_content .= '<div class="sd-content"><ul>';

and it looks like this:
comment position enter image description here

does anyone have an idea why its getting moved there? and how i can move it back where it should be?

share|improve this question
    
comments_popup_link() prints the result, and can therefore not be used in a string concatenation. I am not aware of an equivalent function to return a similar output. –  Michael Jan 13 '13 at 13:06
1  
See core.trac.wordpress.org/ticket/17763 ("comments_popup_link() need a get_* version") –  diggy Jan 13 '13 at 13:08
add comment

2 Answers

up vote 3 down vote accepted

You could probably just buffer the output from comments_popup_link in a separate function.

function get_comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
    ob_start();
    comments_popup_link( $zero, $one, $more, $css_class, $none );
    return ob_get_clean();
}
share|improve this answer
    
thanks this works perfectly and its easy to use. –  domiSchenk Jan 13 '13 at 14:08
    
you might want to prefix the function name to avoid trouble in the future, e.g. wpse80387_get_comments_popup_link –  diggy Jan 13 '13 at 15:01
    
ah thats a good point, thx –  domiSchenk Jan 14 '13 at 7:40
add comment

As @Michael points out, "comments_popup_link() prints the result, and can therefore not be used in a string concatenation" when returning output. There's a patch available, or you could use following workaround, something I wrote a while ago, adapted to your markup:

if ( $global['sharing_label'] != '' ) {
    global $post;
    $comments_link_txt = ( get_comments_number( $post->ID ) != 0 ) ? sprintf( _n( '1 Reply', '%1$s Replies', get_comments_number( $post->ID ), 'changed2012' ), number_format_i18n( get_comments_number( $post->ID ) ) ) : __( 'Leave a reply', 'changed2012' );
    $sharing_content .= '<h3 class="sd-title"><a href="' . get_comments_link( $post->ID ) . '">' . $comments_link_txt . '</a>' . $global['sharing_label'] . '</h3>';
}
share|improve this answer
    
when i apply the patch, does the next update remove the patch again? –  domiSchenk Jan 13 '13 at 13:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.