• Resolved btruxell

    (@btruxell)


    Is there a way to add comments like in blog posts to the pages? I don’t see the option anywhere within the individual page options. Some of my pages are set up with a Virtue Gallery and I selected “allow comments on galleries” under theme options but no comments appear. I have a few tutorials on my site and would like to allow commenting.

    http://www.somethinghdr.com

    Thanks in advance,
    Brad

Viewing 11 replies - 1 through 11 (of 11 total)
  • Currently pages aren’t set up to use comments in virtue, the box you are talking about refers to the portfolio posts. Is there any reason to not make those pages posts?

    If you want to add it yourself you can edit the page template files, just before the closing div add this:

    <?php comments_template('/templates/comments.php'); ?>

    Kadence Themes

    Thread Starter btruxell

    (@btruxell)

    Perfect! It worked.

    Thanks so much!
    Brad

    I just tried this. It added the comments box beautifully but now it isn’t showing the text for the page. What did I do wrong?

    Thread Starter btruxell

    (@btruxell)

    The only thing that I could think of is you may have removed a div for the page’s actual content when inserting the comment div.

    Do you know how I can fix that?

    Thread Starter btruxell

    (@btruxell)

    What is the name of the PHP file that you modified in WordPress for the comments?

    page.blog.php

    Thread Starter btruxell

    (@btruxell)

    Here is my page.blog.php file. Just replace this php file with yours. I would suggest you make a copy of your current file in case this one doesn’t work for you.

    <?php
    /*
    Template Name: Blog
    */
    ?>

    <div id=”pageheader” class=”titleclass”>
    <div class=”container”>
    <?php get_template_part(‘templates/page’, ‘header’); ?>
    </div><!–container–>
    </div><!–titleclass–>

    <div id=”content” class=”container”>
    <div class=”row”>
    <?php if(kadence_display_sidebar()) {$display_sidebar = true; $fullclass = ”;} else {$display_sidebar = false; $fullclass = ‘fullwidth’;}
    global $post; if(get_post_meta( $post->ID, ‘_kad_blog_summery’, true ) == ‘full’) {$summery = ‘full’; $postclass = “single-article fullpost”;} else {$summery = ‘normal’; $postclass = ‘postlist’;} ?>
    <div class=”main <?php echo kadence_main_class();?> <?php echo $postclass .’ ‘. $fullclass; ?>” role=”main”>
    <?php global $post; $blog_category = get_post_meta( $post->ID, ‘_kad_blog_cat’, true );
    if($blog_category == ‘-1’ || $blog_category == ”) {
    $blog_cat_slug = ”;
    } else {
    $blog_cat = get_term_by (‘id’,$blog_category,’category’);
    $blog_cat_slug = $blog_cat -> slug;
    }

    $blog_items = get_post_meta( $post->ID, ‘_kad_blog_items’, true );
    if($blog_items == ‘all’) {$blog_items = ‘-1’;}

    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query(array(
    ‘paged’ => $paged,
    ‘category_name’=>$blog_cat_slug,
    ‘posts_per_page’ => $blog_items));
    $count =0;
    if ( $wp_query ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    <?php if($summery == ‘full’) {
    if($display_sidebar){
    get_template_part(‘templates/content’, ‘fullpost’);
    } else {
    get_template_part(‘templates/content’, ‘fullpostfull’);
    }
    } else {
    if($display_sidebar){
    get_template_part(‘templates/content’, get_post_format());
    } else {
    get_template_part(‘templates/content’, ‘fullwidth’);
    }
    }
    endwhile; else: ?>
    <li class=”error-not-found”><?php _e(‘Sorry, no blog entries found.’, ‘virtue’); ?>
    <?php endif; ?>

    <?php if ($wp_query->max_num_pages > 1) : ?>
    <?php if(function_exists(‘kad_wp_pagenavi’)) { ?>
    <?php kad_wp_pagenavi(); ?>
    <?php } else { ?>
    <nav class=”post-nav”>
    <ul class=”pager”>
    <li class=”previous”><?php next_posts_link(__(‘← Older posts’, ‘virtue’)); ?>
    <li class=”next”><?php previous_posts_link(__(‘Newer posts →’, ‘virtue’)); ?>

    </nav>
    <?php } ?>
    <?php endif; ?>
    <?php $wp_query = null; $wp_query = $temp; // Reset ?>
    <?php wp_reset_query(); ?>

    </div><!– /.main –>

    Thread Starter btruxell

    (@btruxell)

    Also, I think you put the comment div on the wrong php file… This looks like the php file for the main blog page, not individual page posts.

    Awesome! Thank you. That may be possible. Like I said, I have no idea what I’m doing.

    Hi,

    I would really like to add comments to my pages as well. I located the file here: Virtue: Comments (templates/comments.php), and would just like to clarify that the code should go where exactly?

    Here’s the code:
    <?php
    if (post_password_required()) {
    return;
    }

    if (have_comments()) : ?>
    <section id=”comments”>
    <h3><?php printf(_n(‘One Response ‘, ‘%1$s Responses ‘, get_comments_number(), ‘virtue’), number_format_i18n(get_comments_number()), get_the_title()); ?></h3>

    <ol class=”media-list”>
    <?php wp_list_comments(array(‘walker’ => new Kadence_Walker_Comment)); ?>

    <?php if (get_comment_pages_count() > 1 && get_option(‘page_comments’)) : ?>
    <nav>
    <ul class=”pager”>
    <?php if (get_previous_comments_link()) : ?>
    <li class=”previous”><?php previous_comments_link(__(‘← Older comments’, ‘virtue’)); ?>
    <?php endif; ?>
    <?php if (get_next_comments_link()) : ?>
    <li class=”next”><?php next_comments_link(__(‘Newer comments →’, ‘virtue’)); ?>
    <?php endif; ?>

    </nav>
    <?php endif; ?>

    <?php if (!comments_open() && !is_page() && post_type_supports(get_post_type(), ‘comments’)) : ?>
    <?php global $virtue; if(isset($virtue[‘close_comments’])) {$show_closed_comment = $virtue[‘close_comments’]; } else {$show_closed_comment = 1;}
    if($show_closed_comment == 1){ ?>
    <div class=”alert”>
    <?php _e(‘Comments are closed.’, ‘virtue’); ?>
    </div>
    <?php } else { } ?>
    <?php endif; ?>
    </section><!– /#comments –>
    <?php endif; ?>

    <?php if (!have_comments() && !comments_open() && !is_page() && post_type_supports(get_post_type(), ‘comments’)) : ?>
    <?php global $virtue; if(isset($virtue[‘close_comments’])) {$show_closed_comment = $virtue[‘close_comments’]; } else {$show_closed_comment = 1;}
    if($show_closed_comment == 1){ ?>
    <section id=”comments”>
    <div class=”alert”>
    <?php _e(‘Comments are closed.’, ‘virtue’); ?>
    </div>
    </section><!– /#comments –>
    <?php } else { } ?>
    <?php endif; ?>

    <?php if (comments_open()) : ?>
    <section id=”respond”>
    <?php if ( did_action( ‘jetpack_comments_loaded’ ) ) : ?>
    <?php comment_form(); ?>
    <?php else: ?>
    <h3><?php comment_form_title(__(‘Leave a Reply’, ‘virtue’), __(‘Leave a Reply to %s’, ‘virtue’)); ?></h3>
    <p class=”cancel-comment-reply”><?php cancel_comment_reply_link(); ?></p>
    <?php if (get_option(‘comment_registration’) && !is_user_logged_in()) : ?>
    <p><?php printf(__(‘You must be logged in to post a comment.’, ‘virtue’), wp_login_url(get_permalink())); ?></p>
    <?php else : ?>
    <form action=”<?php echo get_option(‘siteurl’); ?>/wp-comments-post.php” method=”post” id=”commentform”>
    <?php if (is_user_logged_in()) : ?>
    <p>
    <?php printf(__(‘Logged in as %s.’, ‘virtue’), get_option(‘siteurl’), $user_identity); ?>
    ” title=”<?php __(‘Log out of this account’, ‘virtue’); ?>”><?php _e(‘Log out »’, ‘virtue’); ?>
    </p>
    <?php else : ?>
    <div class=”row”>
    <div class=”col-md-4″>
    <label for=”author”><?php _e(‘Name’, ‘virtue’); if ($req) _e(‘ <span>*</span>’, ‘virtue’); ?></label>
    <input type=”text” class=”text” name=”author” id=”author” value=”<?php echo esc_attr($comment_author); ?>” <?php if ($req) echo ‘aria-required=”true”‘; ?>>
    </div>
    <div class=”col-md-4″>
    <label for=”email”><?php _e(‘Email (will not be published)’, ‘virtue’); if ($req) _e(‘ <span>*</span>’, ‘virtue’); ?></label>
    <input type=”email” class=”text” name=”email” id=”email” value=”<?php echo esc_attr($comment_author_email); ?>” <?php if ($req) echo ‘aria-required=”true”‘; ?>>
    </div>
    <div class=”col-md-4″>
    <label for=”url”><?php _e(‘Website’, ‘virtue’); ?></label>
    <input type=”url” class=”text” name=”url” id=”url” value=”<?php echo esc_attr($comment_author_url); ?>”>
    </div>
    </div>
    <?php endif; ?>
    <label for=”comment”><?php _e(‘Comment’, ‘virtue’); ?></label>
    <textarea name=”comment” id=”comment” class=”input-xlarge” rows=”5″ aria-required=”true”></textarea>
    <p><input name=”submit” class=”kad-btn kad-btn-primary” type=”submit” id=”submit” value=”<?php _e(‘Submit Comment’, ‘virtue’); ?>”></p>
    <?php comment_id_fields(); ?>
    <?php do_action(‘comment_form’, $post->ID); ?>
    </form>
    <?php endif; ?>
    <?php endif; ?>
    </section><!– /#respond –>
    <?php endif; ?>

    I’d really appreciate your help! Not to savvy with the php…!

    Thanks,
    Lina

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Comment on pages’ is closed to new replies.