I'll explain what I am trying to accomplish.
I would like to have regular non-threaded (flat/classic) comments with a reply link to each comment. When someone replies to a comment the reply comment will end up at the top (or bottom) as the latest comment just as it would in the default non-threaded comments, but unlike the default non-threaded comment the reply should display a link to the original comment/author.
There is a proposed solution over at the wordpress forum:
http://wordpress.org/support/topic/reply-to-link-for-chronological-non-threaded-comments
I just don't get it to work. I am not sure in what files the poster is placing the different pieces of code. I tried to use the code and hook a function to comment_post:
add_action('comment_post', 'print_reply_link', 10, 2);
function print_reply_link( $comment_id, $approved ){
if( $approved ){
$comment = get_comment( $comment_id );
if ( $comment->comment_parent ) {
$parent = get_comment( $comment->comment_parent );
$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
printf( ' in reply to <a href="%1$s">%2$s</a>', $parent_link, $parent->comment_author );
}
}
}
This returned a blank page with "in reply to authorname". After reloading the post a reply comment shows up correctly but without any link to the original comment
My coding skills are really very basic so I have no good idea how I should proceed. Would be very grateful for any help.
href
in thea
that follows 'in reply to` as per the 'Inspect Element' tool in Chrome (or similar in your browser of choice)?s
in%1$s
means that the argument is treated as and presented as a string. This is explained in detail in the php manual for the the sprintf function: php.net/manual/en/function.sprintf.php