-
AuthorPosts
-
January 24, 2015 at 9:21 am #190766
Hey,
I want to have comments on a specific page.
I’m using a blank template so it does not output the comments. Is there a way to add them as an element to a page ?
January 25, 2015 at 7:59 pm #191366Hi Steve,
Thanks for writing in.
What stacks you’re working on? Follow this instruction for integrity.
Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
Add this code at your child theme’s functions.php
add_shortcode('x_comment_embed', 'x_comment_embed'); function x_comment_embed ( $atts ) { ob_start(); if ( post_password_required() ) return; // 1 ?> <div id="comments" class="x-comments-area"> <?php if ( have_comments() ) : ?> <h2 class="h-comments-title"><span><?php _e( 'Comments' , '__x__' ); ?> <small><?php echo number_format_i18n( get_comments_number() ); ?></small></span></h2> <ol class="x-comments-list"> <?php wp_list_comments( array( 'callback' => 'x_integrity_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> <?php return ob_get_clean(); }
Then just add
[x_comment_embed]
inside your page content that has blank template.Hope this helps.
January 26, 2015 at 2:56 pm #192101Perfect as always 🙂
Thank you
January 27, 2015 at 3:02 am #192488You’re welcome! 🙂
April 2, 2015 at 5:24 am #240625Hello Themeco Staff
I have the same problem with icon stack, and adding this code at my child theme I can see the comments form but not the list of comments.
Can you help me, please?April 2, 2015 at 6:42 am #240660Hi,
Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.
May 6, 2015 at 6:21 pm #267626I’m using Integrity. I set up a child theme and added the code to functions.php, and then [x_comment_embed] to the page. I see the submit form, but not existing comments.
Please help
Thanks.
May 6, 2015 at 6:45 pm #267641This reply has been marked as private.May 6, 2015 at 11:03 pm #267827Hi,
Thank you for providing your url.
We can try another approach for this.
Please copy the file template-blank-6.php from wp-content/themes/x/framework/views/integrity
into your child theme wp-content/themes/x-child/framework/views/integrityThen edit the file that is in your child theme and add the code
<?php x_get_view( 'global', '_comments-template' ); ?>
after the line<?php endwhile; ?>
Code in your template-blank-6.php file will look like this.
<?php // ============================================================================= // VIEWS/INTEGRITY/TEMPLATE-BLANK-6.PHP (No Container | No Header, No Footer) // ----------------------------------------------------------------------------- // A blank page for creating unique layouts. // ============================================================================= ?> <?php x_get_view( 'global', '_header' ); ?> <?php x_get_view( 'global', '_slider-above' ); ?> <?php x_get_view( 'global', '_slider-below' ); ?> <div class="x-main full" role="main"> <?php while ( have_posts() ) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php x_get_view( 'global', '_content', 'the-content' ); ?> </article> <?php endwhile; ?> <?php x_get_view( 'global', '_comments-template' ); ?> </div> <?php x_get_view( 'global', '_footer', 'scroll-top' ); ?> <?php x_get_view( 'global', '_footer' ); ?>
Please do the same for the other blank templates(template-blank-1.php,template-blank-2.php,template-blank-3.php…..) you want to use.
Hope that helps.
May 7, 2015 at 12:13 pm #268303This reply has been marked as private.May 7, 2015 at 5:53 pm #268548Hi there,
Could you try adding this at your child theme’s functions.php
add_post_type_support( 'page', ''comments' );
Then edit your specific page and go to Screen Options on top and see if Discussion is available. If available, then enable it and scroll down to find Discussion section and turn or off comments.
Hope this helps.
May 7, 2015 at 6:40 pm #268576Yes, that worked – thank you. You had an extra single quote before ‘comments’ that I needed to remove.
I can now toggle the comments on and off.
The comments are STILL outside of the content band / container that I would like them in. They stretch across the entire screen and look weird. Any ideas for correcting that?
May 7, 2015 at 10:09 pm #268711Hello There,
Sorry for the typo error.
Please try to check the code below, the x-main full div doesn’t have a closing. We just made some revision:
<?php // ============================================================================= // VIEWS/INTEGRITY/TEMPLATE-BLANK-6.PHP (No Container | No Header, No Footer) // ----------------------------------------------------------------------------- // A blank page for creating unique layouts. // ============================================================================= ?> <?php x_get_view( 'global', '_header' ); ?> <?php x_get_view( 'global', '_slider-above' ); ?> <?php x_get_view( 'global', '_slider-below' ); ?> <div class="x-main full" role="main"> <?php while ( have_posts() ) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php x_get_view( 'global', '_content', 'the-content' ); ?> </article> <?php endwhile; ?> <div class="x-container max width"> <?php x_get_view( 'global', '_comments-template' ); ?> </div> </div> <?php x_get_view( 'global', '_footer', 'scroll-top' ); ?> <?php x_get_view( 'global', '_footer' ); ?>
Please let us know how it goes.
May 8, 2015 at 11:08 am #269115Wooooohooooo! THANK YOU. That worked perfectly.
May 8, 2015 at 2:49 pm #269234You’re welcome! 🙂
-
AuthorPosts