Support » Fixing WordPress » Comments can be answered by the admin only and show nested?

  • Resolved eatmorerice

    (@eatmorerice)


    Hello,

    I would like that comments can only be answered by the admin, therefore I deactivated the option of “threaded comments”.

    But this results in that answers to comments by the admin are shown at the end of all comments and not directly below the relevnat comment.

    Is there a solution to show comments nested but do not allow public comments on comments?

    Thanks and regards,
    Irene

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    This is possible, but you have to change theme template files. What theme are you using? (link please)

    Thread Starter eatmorerice

    (@eatmorerice)

    I’ve just noticed that the latest wp-theme (http://wordpress.org/extend/themes/twentyeleven) shows them at least in the correct order (although not nested).

    If someone could give me a hint how to show them nested too I’d be very happy 🙂

    Moderator keesiemeijer

    (@keesiemeijer)

    twenty eleven is the theme you use then?

    Thread Starter eatmorerice

    (@eatmorerice)

    Yes.

    Moderator keesiemeijer

    (@keesiemeijer)

    Enable threaded comments again. Create a child theme for these modifications

    In your (child theme’s) header.php change this:

    /* We add some JavaScript to pages with the comment form
    * to support sites with threaded comments (when in use).
    */
    	if ( is_singular() && get_option( 'thread_comments' ) ) {
               wp_enqueue_script( 'comment-reply' );
    	}

    to this:

    /* We add some JavaScript to pages with the comment form
    * to support sites with threaded comments (when in use).
    */
    	if ( is_singular() && get_option( 'thread_comments' ) ) {
    	  if(current_user_can('administrator')) {
    		wp_enqueue_script( 'comment-reply' );
    	  }
    	}

    in your (child theme’s) functions.php change this:

    <div class="reply">
    				<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    			</div><!-- .reply -->

    to this:

    <?php if (current_user_can('administrator')) : ?>
    			<div class="reply">
    				<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply <span>&darr;</span>', 'twentyeleven' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    			</div><!-- .reply -->
    			<?php endif; ?>

    Thread Starter eatmorerice

    (@eatmorerice)

    Thanks for the instruction. Unfortunately I must be doing something wrong, as changing the functions.php (in my childs theme) breaks the whole site.

    As I do not have access to the logs I do not see what exactly causes the error.
    I copied the functions.php from the original-theme and changed the code you stated (by copy & paste, so no typos). Is this the correct way?

    Moderator keesiemeijer

    (@keesiemeijer)

    I just read this:
    http://codex.wordpress.org/Child_Themes#Using_functions.php
    Make a new (blanco) (child) functions.php
    copy the whole function twentyeleven_comment (with your modifications in it) from the parent theme:
    it starts here: if ( ! function_exists( 'twentyeleven_comment' ) ) :
    and ends here: endif; // ends check for twentyeleven_comment()

    Paste it in your new child functions.php.

    change the function name in :
    if ( ! function_exists( 'twentyeleven_comment' ) ) :
    and here: function twentyeleven_comment( $comment, $args, $depth ) {...rest of function ...}
    to my_twentyeleven_comment like so:
    change the function name in :
    if ( ! function_exists( 'my_twentyeleven_comment' ) ) :
    and here: function my_twentyeleven_comment( $comment, $args, $depth ) {...rest of function ...}

    now in comments.php change this:
    wp_list_comments( array( 'callback' => 'twentyeleven_comment' ) );
    to:
    wp_list_comments( array( 'callback' => 'my_twentyeleven_comment' ) );
    And save your new (child) functions.php

    Thread Starter eatmorerice

    (@eatmorerice)

    Thanks you very much, now it work!

    The trick of this modification is not, that answers to comments are shown nested although it is de-activated, but that only the admin can reply to comments although threaded comments are activated, right?

    Moderator keesiemeijer

    (@keesiemeijer)

    but that only the admin can reply to comments although threaded comments are activated, right?

    Yes.
    Create a new user with a different “Role” as administrator and login as this new User to see if it works.

    I also just learned that you could also just copy paste the function “twentyeleven_comment” with the alterations (if (current_user_can('administrator'))) in your new blanco child theme functions.php without changing the function name (my_twentyeleven_comment) and without changing comments.php.

    Thread Starter eatmorerice

    (@eatmorerice)

    May again ask for your help? I switched the theme to “brand new day” (http://wordpress.org/extend/themes/brand-new-day) but couldn’t find the passage where the answer-link to comments is created (in the functions.php or another file).

    I appreciate any help!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Comments can be answered by the admin only and show nested?’ is closed to new replies.