Tagged: x
-
AuthorPosts
-
August 14, 2016 at 4:34 pm #1131035
MattModeratorHi Guys!
Can you help me with a little php please?
I want to change the comments title from “One Comment on [Post Title]” to say “Reader Comments (1)” where the number of comments is updated dynamically.
I understand that it is this part of the wp-comments.php file that I need to alter:
<?php printf( _n( 'One Comment on %2$s', '%1$s Comments on %2$s', get_comments_number(), '__x__' ), number_format_i18n( get_comments_number() ), '<span>“' . get_the_title() . '”</span>' ); ?>Can you please tell me what I need to alter it to?
Appreciate you guys as always 🙂
August 14, 2016 at 9:33 pm #1131301
Rue NelModeratorHello There,
Thanks for writing in! To change the comments title, I am just assuming that you are using Renew stack. Please follow the following:
1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2] Insert the following code into that new file<?php // ============================================================================= // VIEWS/RENEW/WP-COMMENTS.PHP // ----------------------------------------------------------------------------- // The area of the page that contains both current comments and the comment // form. The actual display of individual comments is handled by a callback to // the x_comment() function. // ============================================================================= ?> <?php // // 1. If the current post is protected by a password and the visitor has not // yet entered the password, we will return early without loading the // comments. // if ( post_password_required() ) return; // 1 ?> <div id="comments" class="x-comments-area"> <?php if ( have_comments() ) : ?> <h2 class="h-comments-title"> <?php printf( _n( 'Reader Comments (%1$s)', 'Reader Comments (%1$s)', get_comments_number(), '__x__' ), number_format_i18n( get_comments_number() ), '<span>“' . get_the_title() . '”</span>' ); ?> </h2> <ol class="x-comments-list"> <?php wp_list_comments( array( 'callback' => 'x_renew_comment', 'style' => 'ol' ) ); ?> </ol> <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?> <nav id="comment-nav-below" class="navigation" role="navigation"> <h1 class="visually-hidden"><?php _e( 'Comment navigation', '__x__' ); ?></h1> <div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', '__x__' ) ); ?></div> <div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', '__x__' ) ); ?></div> </nav> <?php endif; ?> <?php if ( ! comments_open() && get_comments_number() ) : ?> <p class="nocomments"><?php _e( 'Comments are closed.' , '__x__' ); ?></p> <?php endif; ?> <?php endif; ?> <?php comment_form( array( 'comment_notes_after' => '', 'id_submit' => 'entry-comment-submit', 'label_submit' => __( 'Submit' , '__x__' ) ) ); ?> </div>3] Save the file named as
wp-comments.php
4] Upload this file to your server in the child theme’s folder
wp-content/themes/x-child/framework/views/renew/We would loved to know if this has work for you. Thank you.
August 15, 2016 at 2:11 am #1131477
MattModeratorThanks Rue, that worked. I’ve ended up modifying it further, so this is resulting code:
<?php // ============================================================================= // VIEWS/RENEW/WP-COMMENTS.PHP // ----------------------------------------------------------------------------- // The area of the page that contains both current comments and the comment // form. The actual display of individual comments is handled by a callback to // the x_comment() function. // ============================================================================= ?> <?php // // 1. If the current post is protected by a password and the visitor has not // yet entered the password, we will return early without loading the // comments. // if ( post_password_required() ) return; // 1 ?> <div id="comments" class="x-comments-area"> <?php if ( have_comments() ) : ?> <h2 class="h-comments-title"> <?php printf( _n( 'One Reader Comment %2$s', '%1$s Reader Comments %2$s', get_comments_number(), '__x__' ), number_format_i18n( get_comments_number() ), '<span>“' . get_the_title() . '”</span>' ); ?> </h2> <ol class="x-comments-list"> <?php wp_list_comments( array( 'callback' => 'x_renew_comment', 'style' => 'ol' ) ); ?> </ol> <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?> <nav id="comment-nav-below" class="navigation" role="navigation"> <h1 class="visually-hidden"><?php _e( 'Comment navigation', '__x__' ); ?></h1> <div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', '__x__' ) ); ?></div> <div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', '__x__' ) ); ?></div> </nav> <?php endif; ?> <?php if ( ! comments_open() && get_comments_number() ) : ?> <p class="nocomments"><?php _e( 'Comments are closed.' , '__x__' ); ?></p> <?php endif; ?> <?php endif; ?> <?php comment_form( array( 'title_reply' => __( '<span>Leave a Comment</span>' , '__x__' ), 'comment_notes_after' => '', 'id_submit' => 'entry-comment-submit', 'label_submit' => __( 'Post Comment' , '__x__' ) ) ); ?> </div>And with a little styling, the attached is the how the page looks. Thanks for your help 🙂
August 15, 2016 at 2:26 am #1131496
RupokMemberYou are welcome!
Feel free to let us know if you face any other issue. We’ll be happy to assist you.
Thanks for using X.
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1131035 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
