-
AuthorPosts
-
April 2, 2015 at 2:58 pm #240981
Hello,
How can I add comments to one of my pages. No container, footer, header layout.
Of course I have the comments turn on, but they just don’t appear on the page.I tried to use following suggestions: https://theme.co/x/member/forums/topic/comments-on-blank-template-2/#post-191366
It worked but for normal comment system. Please notice that I’m using your Discqus extension.Thanks in advance!
SimonApril 2, 2015 at 5:33 pm #241061Hello Simon,
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. Along with that if you could specify the page name on which you ar trying to implement Discus comments.
Thanks.
April 2, 2015 at 6:32 pm #241110This reply has been marked as private.April 2, 2015 at 9:50 pm #241200Hello There,
To add the comments to page templates, simply download the page template file from
/wp-content/themes/x/framework/views/{your-stack}/template-blank-1.php
(just an example) and upload it to your child theme folder/wp-content/themes/x-child/framework/views/{your-stack}/template-blank-1.php
. You can then add the comments template in this page template. The code should look like this below:<?php // ============================================================================= // VIEWS/INTEGRITY/TEMPLATE-BLANK-1.PHP (Container | Header, Footer) // ----------------------------------------------------------------------------- // A blank page for creating unique layouts. // ============================================================================= ?> <?php get_header(); ?> <div class="x-container max width offset"> <div class="x-main full" role="main"> <?php while ( have_posts() ) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="entry-wrap"> <?php x_get_view( 'global', '_content', 'the-content' ); ?> </div> </article> <?php /* This is the comments template */ ?> <?php x_get_view( 'global', '_comments-template' ); ?> <?php endwhile; ?> </div> </div> <?php get_footer(); ?>
We used the Blank page template (Container, Header | Footer) as an example. Feel free to use the page template that you will need to use. Just insert the comments template in it and you good to go!
This is the code for the comments template:
<?php /* This is the comments template */ ?> <?php x_get_view( 'global', '_comments-template' ); ?>
Please let us know how it goes.
April 3, 2015 at 2:49 am #241328This is a code I use instead of yours
<div class="x-container max width wpb_row"> <?php if( get_post_meta( get_the_ID(), 'comment_visibility', true ) == 'visible' ) x_get_view( 'global', '_comments-template' ); ?> </div>
That’s becouse I want to have comments only on particular sites. My question is more or less PHP related, becouse I cannot find a way to put the <div> section into “if”. I have to use div becouse I want comments to be in a “inner container”.
BTW is there a way to use functions.php instead of changing template? Like you suggest for normal type comments?
https://theme.co/x/member/forums/topic/comments-on-blank-template-2/#post-191366April 3, 2015 at 3:01 am #241333Hello Again,
You can replace the code
<?php /* This is the comments template */ ?> <?php x_get_view( 'global', '_comments-template' ); ?>
with your code. That is the easiest way to have the comments template in your page template. If you do not want to edit a template, you can always create a custom template in your child theme. Please copy this code into a new file and save it as template-custom.php. Upload this file in to your child theme’s folder and you can have a new page template.
<?php // ============================================================================= // TEMPLATE NAME: Custom Blank - Container | Header, Comment, Footer // ----------------------------------------------------------------------------- // A custom blank page template with comments template // // ============================================================================= ?> <?php get_header(); ?> <div class="x-container max width offset"> <div class="x-main full" role="main"> <?php while ( have_posts() ) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="entry-wrap"> <?php x_get_view( 'global', '_content', 'the-content' ); ?> </div> </article> <div class="x-container max width wpb_row"> <?php if( get_post_meta( get_the_ID(), 'comment_visibility', true ) == 'visible' ) x_get_view( 'global', '_comments-template' ); ?> </div> <?php endwhile; ?> </div> </div> <?php get_footer(); ?>
In this method, no templates has been tampered. You just created a new page template.
Please let us know how it goes.
April 3, 2015 at 5:43 pm #241793That’s working great, but there is one more issue.
The first screen shows my old version of code:
The second one shows the same page, but using custom template:
I have no idea where does that white bar came from. Also I dont know how to remove it. I’d love to use the custom template if we could figure it out.
April 3, 2015 at 5:51 pm #241797Here is current code of template-custom.php
<?php // ============================================================================= // TEMPLATE NAME: Custom Blank - Container | Header, Comment, Footer // ----------------------------------------------------------------------------- // A custom blank page template with comments template // // ============================================================================= ?> <?php get_header(); ?> <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' ); ?> <div class="x-content-band vc bg-pattern man" style="background-color: #F2F1EF; padding-top: 0px; padding-bottom: 40px;"> <div class="x-container max width wpb_row"> <div class="x-container wpb_row"> <div class="x-column x-sm vc x-1-1" style=""><img class="x-img mtn mbn x-img-none none" src="http://gitara.tv/wp-content/uploads/2015/04/shadow3.png"></div></div> <h3 class="h-custom-headline mtn mbn center-text h3 accent"><span>Komentarze</span></h3> <?php x_get_view( 'global', '_comments-template' ); ?> </div></div> </article> <?php endwhile; ?> </div> <?php get_footer(); ?>
But I also tried to compy template-blank-4 code into the template-custom and there is still this white bar on the top.
April 3, 2015 at 8:34 pm #241876Hello There,
To remove the white border, please add the following css code in the customizer, Appearance > Customize > Custom > CSS
.page .entry-content { margin-top: 0px; }
Hope this helps.
April 4, 2015 at 3:47 am #241992Whooaa! We made it. Thank you :))
April 4, 2015 at 4:06 am #241999Hello Again,
You are most welcome!
It’s good to know that we were able to help and most of the codes worked out for you.Cheers,
XOctober 13, 2015 at 1:00 pm #623595Hi, I would like to add comments to a page also. I am not using child theme, nor do I want to go through the code changes explained in this article. Is there any plans in a future update to make the “Allow Comments” WP option work for the pages and not just posts?
October 13, 2015 at 1:02 pm #623599Hi Steven,
We certainly appreciate the feedback! This is something we can add to our list of feature requests. This way it can be taken into consideration for future development. All of these items are discussed with our team internally and prioritized based on the amount of interest a particular feature might receive.
In the meantime, comments are possible to show in pages if you select any layout page template except “Layout – Portfolio” (see: http://prntscr.com/8qxafq).
Thanks!
-
AuthorPosts