0

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?

2
  • 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, 2013 at 13:06
  • 1
    See core.trac.wordpress.org/ticket/17763 ("comments_popup_link() need a get_* version")
    – diggy
    Jan 13, 2013 at 13:08

2 Answers 2

4

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();
}
2
  • you might want to prefix the function name to avoid trouble in the future, e.g. wpse80387_get_comments_popup_link
    – diggy
    Jan 13, 2013 at 15:01
  • ah thats a good point, thx
    – domiSchenk
    Jan 14, 2013 at 7:40
1

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>';
}
1
  • when i apply the patch, does the next update remove the patch again?
    – domiSchenk
    Jan 13, 2013 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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