Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #240981

    Szymon
    Participant

    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!
    Simon

    #241061

    Prasant Rai
    Moderator

    Hello 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.

    #241110

    Szymon
    Participant
    This reply has been marked as private.
    #241200

    Rue Nel
    Moderator

    Hello 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.

    #241328

    Szymon
    Participant

    This 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-191366

    #241333

    Rue Nel
    Moderator

    Hello 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.

    #241793

    Szymon
    Participant

    That’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.

    http://gitara.tv/przekonania-a-twoj-muzyczny-potencjal

    #241797

    Szymon
    Participant

    Here 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.

    #241876

    Rue Nel
    Moderator

    Hello 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.

    #241992

    Szymon
    Participant

    Whooaa! We made it. Thank you :))

    #241999

    Rue Nel
    Moderator

    Hello 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,
    X

    #623595

    stevenwalter0
    Participant

    Hi, 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?

    #623599

    Zeshan
    Member

    Hi 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!