Forums

Comments & Post List on Pages (1 post)

  1. jenngpicz
    Member
    Posted 1 week ago #

    Would really appreciate help with the following, thanks :)

    Trying to have Comments and a list of Posts from a particular category on a Page.

    Everything is visible, but the COMMENTS will only show if the Post list is below the comments code, otherwise is shows the form and "no comments to show".

    I don't think this was a problem until 2.5.1 but can't be certain. Only related plugin is Gravtars.

    Is it to do with the endofeach, endif... ?

    <?php
    /*
    Template Name: Test page
    */
    ?>
    
    <?php get_header(); ?>
    <!--page.php-->
    <div id="content">
    
    	<!--loop-->
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<!--post title-->
    	<h1 class="btmspace" id="post-<?php the_ID(); ?>"><?php the_title(); ?></h1>
    	<!--post with more link -->
    	<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    	<!--if you paginate pages-->
    	<?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
    
    <!-- POSTS FOR THIS CATEGORY -->
     <h6>Posts for this category</h6>
     <?php
     global $post;
     $myposts = get_posts('numberposts=10&category=15');
     foreach($myposts as $post) :
     ?>
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
     <?php endforeach; ?>
    <!-- POSTS FOR THIS CATEGORY end -->
    
    <!-- COMMENTS CODE -->
    <?php if ( comments_open() ) comments_template(); ?>
    <!-- COMMENTS CODE end -->
    <?php endwhile; endif; ?>
    <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    
    </div>
    
    <!--page.php end-->
    <!--include sidebar-->
    <?php get_sidebar();?>
    <!--include footer-->
    <?php get_footer(); ?>

Reply

You must log in to post.

About this Topic