WordPress.org

Forums

Add posts and comments to specifc pages of my blog (2 posts)

  1. naples07
    Member
    Posted 7 years ago #

    I have created sub pages on my blog and would like to post and receive comments on those pages - how do I do that?

  2. richarduk
    Member
    Posted 7 years ago #

    You have to create a page template that allows for comments.

    Without knowing your template all I can do is post the rough outline for the code.

    You need to insert something like this:

    <?php if (have_posts()) : ?>    
    
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="post" id="post-<?php the_ID();?>">
    
    <h3><?php the_title(); ?></h3>
    
    <div class="entry">
    
    <?php the_content(); ?> 
    
    <p>Posted by <?php the_author();?> on <?php the_time('l F jS Y');?> in the following categories:
    <?php the_category(', ') ?></p>
    
    <p><?php comments_number('No Responses', 'One Response', '% Responses');?> to “<?php the_title(); ?>”</p> 
    
    </div>                 
    
    <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) { ?>
    
    <p>You can comment <a href="#respond">here</a> or leave a <a href="<?php trackback_url(true); ?>" rel="trackback">trackback</a> from your site.  Keep an eye on the most recent comments to this post using the  <?php comments_rss_link(' RSS feed'); ?></p>
    
    <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) { ?>
    
    <p>You can't leave comments on this post but you can leave  <a href="<?php trackback_url(true); ?> " rel="trackback">trackbacks</a>.</p>
    
    <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) { ?>
    
    <p>You can leave  <a href="#respond">comments</a> on this post but not trackbacks. Keep an eye on the most recent comments using the  <?php comments_rss_link(' RSS feed'); ?>.</p>
    
    <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) { ?>
    
    <p>Sorry, no comments or trackbacks are allowed on this post.</p>
    
    <?php }?>
    
    <?php edit_post_link('Edit this page', '', ' '); ?> 
    
    <?php wp_link_pages(); ?> 
    
    </div>                    
    
    <?php comments_template(); ?>
    
    <?php endwhile; ?> 
    
    <?php else : ?>
    
    <p>Sorry, what you're looking for can't be found. Does it exist?</p>
    
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic