• Hi,

    I just launched a new blog, and have discovered that only 1 post shows on the main page. I have 10 posts per page set in the settings. After reviewing other questions in the forum, it may be that the posts are hardcoded on the index.php, but I’m not sure.

    I have posted the code below. If it is hardcoded, how can I undo that and get it to add more than 1 blog post on the page?

    <?php get_header(); ?>
    
    	<div id="content_box">
    
    		<div id="content" class="posts">
    
    		<?php if (have_posts()) : ?>
    
    			<?php while (have_posts()) : the_post(); ?>
    
    			<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    				<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				<h4><?php the_time('F jS, Y'); ?><!-- by <?php the_author() ?> --> &middot; <?php the_category(', '); ?> <?php edit_post_link('Edit', ' &middot; ', ''); ?></h4>
    				<div class="entry">
    					<?php the_content('[Read more &rarr;]'); ?>
    				</div>
    				<p class="tagged"><span class="add_comment"><?php comments_popup_link('&rarr; No Comments', '&rarr; 1 Comment', '&rarr; % Comments'); ?></span><strong>Tags:</strong><?php the_tags('','&middot;',''); ?></p>
    				<div class="clear"></div>
    			</div>
    
    			<?php endwhile; ?>
    
    			<?php include (TEMPLATEPATH . '/navigation.php'); ?>
    
    		<?php else : ?>
    
    			<h2 class="page_header center">Not Found</h2>
    			<div class="entry">
    				<p class="center">Sorry, but you are looking for something that isn't here.</p>
    				<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    			</div>
    
    		<?php endif; ?>
    
    		</div>
    
    		<?php get_sidebar(); ?>
    
    	</div>
    
    <?php get_footer(); ?>

    Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • There’s no sign of a custom query limiting posts per page to 1 in the code you posted above.

    Thread Starter antorera

    (@antorera)

    Okay. Then why won’t my page show more than one post?

    A link to your site might help…

    Thread Starter antorera

    (@antorera)

    Of course! I had inserted the code but forgot the link:
    http://inthegarlic.com/

    Thanks!

    Thread Starter antorera

    (@antorera)

    I’ve been troubleshooting with removing or replacing code and removing plugins, but still can’t get the page to show more than 1 post. Any ideas?

    http://www.inthegarlic.com

    Thanks.

    Have you checked your posts per page settings in Admin/Settings/Reading? Only your date archives have more than 1 post per page – which suggests that perhaps the archive uses a custom query but that the rest of the templates are using the above setting.

    Thread Starter antorera

    (@antorera)

    Yes, I do have 10 posts per page settings in the readings setting.

    I’m posting the code again (up to the sidebar call) because the one above isn’t what I currently have. I’ve been trying to add the <?php if(have_posts()) : ?><?php while <have_posts()) : the_post(); ?> statement, which seems to be what’s missing on the current index page. However, whenever I add it, I get a parsing error and the page doesn’t load:

    Parse error: syntax error, unexpected ‘<‘, expecting ‘(‘ in /home/inthega1/public_html/wordpress/wp-content/themes/InTheGarlic/index.php on line 3

    Maybe I’m not putting the end while statement in the right place?

    <?php get_header(); ?>
    
    <?php if (have_posts()) : the_post(); ?>
    
    <!-- start content -->
    <div id="content">
    	<div class="post" id="post-<?php the_ID(); ?>">
    		<h1 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
    		<p class="meta"><small>Posted on <?php the_time('F jS, Y') ?> by <?php the_author() ?> <?php edit_post_link('Edit', ' | ', ''); ?></small></p>
    		<div class="entry">
    			<?php the_content('Read the rest of this entry &raquo;'); ?>
    		</div>
    		<p class="links"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> &nbsp;&nbsp;&nbsp; <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Permalink</a></p>
    		<p class="tags"><?php the_tags('Tags: ', ', ', ' '); ?></p>
    	</div>
    
    </div>
    <!-- end content -->
    
    <?php else : ?>
    
    	<h2 class="center">Not Found</h2>
    	<p class="center">Sorry, but you are looking for something that isn't here.</p>
    	<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    <?php endif; ?>

    Try <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Thread Starter antorera

    (@antorera)

    Thanks, but this caused the same parsing error I referred to above. 🙁

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Only 1 blog post showing on front page’ is closed to new replies.