WordPress.org

Ready to get started?Download WordPress

Forums

Why isn't my loop looping and why is it only showing pages? (1 post)

  1. a4jp.com
    Member
    Posted 2 years ago #

    I have lots of posts with categories but my loop is only showing one page. This is the code I'm using with the Twenty Eleven theme.

    I made a page and used this as a template for that page.

    <?php
    /*
    Template Name: a4jp.com Loop
    */
    /*
     *
     * The template for displaying all pages.
     *
     * This is the template that displays all pages by default.
     * Please note that this is the WordPress construct of pages
     * and that other 'pages' on your WordPress site will use a
     * different template.
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
    
    get_header(); ?>
    
            <div id="primary">
    			<div id="content" role="main">
    
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php get_template_part( 'content', 'post' ); ?>
    
    					<!--<php comments_template( '', true ); ?>-->
    
    				<?php endwhile; // end of the loop. ?>
    
                    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
    
    	<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    		<?php the_title('<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">', '</a></h2>'); ?>
    
    		<p class="byline">
    			<span class="author vcard"><?php the_author_posts_link(); ?></span> <span class="sep">|</span>
    			<abbr class="published" title="<?php the_time(__('l, F jS, Y, g:i a', 'example')); ?>"><?php the_time(__('F j, Y', 'example')); ?></abbr>
    			<?php edit_post_link(__('Edit', 'example'), ' <span class="sep">|</span> <span class="edit">', '</span> '); ?>
    		</p>
    
    		<div class="entry-content">
    			<?php the_content(__('Continue reading', 'example')); ?>
    			<?php wp_link_pages('before=<p class="pages">' . __('Pages:','example') . '&after=</p>'); ?>
    		</div>
    
    		<p class="entry-meta">
    			<span class="categories"><?php _e('Posted in', 'example'); ?> <?php the_category(', '); ?></span>
    			<?php the_tags('<span class="tags"> <span class="sep">|</span> ' . __('Tagged', 'example') . ' ', ', ', '</span>'); ?>
    			<span class="sep">|</span> <?php comments_popup_link(__('Leave a response', 'example'), __('1 Response', 'example'), __('% Responses', 'example'), 'comments-link', __('Comments closed', 'example')); ?>
    		</p>
    
    	</div>
    
    	<?php endwhile; ?>
    
    <?php else : ?>
    
    	<p class="no-posts"><?php _e('Sorry, no posts matched your criteria', 'example'); ?></p>
    
    <?php endif; ?>	
    
    			</div><!-- #content -->
    		</div><!-- #primary -->
    
    <?php get_footer(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic