Forums

WP_Query Problem With Database (3 posts)

  1. smartfinds
    Member
    Posted 9 months ago #

    Hello,

    Having the darnedest time trying to figure this out.

    The Posts table has 5 posts that are setup with Post Type "Foundation". Unfortunately, only 3 of them are being displayed. It is a very strange situation. The segment of code that is controlling this in the file home.php is and the area in question is the section with WP_Query.

    <?php
    /*
    Template Name: Fron Page Layout
    */
    get_header(); ?>
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <div class="content-home">
    	<div class="box_main_page">
    		<div class="title">
    			<?php $custom = get_post_custom($post->ID); ?>
    			<?php $slogan = (empty($custom['slogan'][0]) ? '' : $custom['slogan'][0]); ?>
    			<h2><?php echo $slogan; ?></h2>
    		</div>
    
    		<?php $loop = new WP_Query(array( 'post_type' => 'foundation', 'orderby' => 'title', 'order' => 'ASC', 'numberposts' => 4 )); ?>
    		<?php $column_classes = array('column_one', 'column_two', 'column_three', 'column_four'); ?>
    		<?php if ($loop->have_posts()) while ($loop->have_posts()) : $loop->the_post(); ?>
    		<div class="<?php echo current($column_classes); next($column_classes); ?>">
    			<span class="letter"><?php the_title(); ?></span>
    			<div class="excerpt"><?php the_excerpt(); ?></div>
    			<?php the_content(); ?>
    		</div>
    		<?php endwhile; ?>
    		<div class="clear"></div>
    	</div>
    	<p>&nbsp;</p>
    	<?php $loop = new WP_Query(array( 'post_type' => 'post', 'category_name' => 'selected', 'orderby' => 'post_date', 'order' => 'DESC', 'numberposts' => 5, 'posts_per_page' => 5 )); ?>
    
    	<?php if ($loop->have_posts()) while ($loop->have_posts()) : $loop->the_post(); ?>
    	<div class="post">
    		<div class="title">
    			<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    		</div>
    		<p><?php the_post_thumbnail(); ?></p>
    		<div class="post_short"><?php the_excerpt(); ?></div>
    	</div>
    
    	<?php endwhile; ?>
    </div>
    <?php endwhile; ?>
    <?php get_footer(); ?>

    Anyone have any thoughts as to what might be wrong here? It's probably something silly, but I've spent hours trying to find it and I'm probably seeing double at this point.

    Thanks for any feedback.

  2. Tom Lynch
    Member
    Posted 9 months ago #

    Are you sure your site isn't setup with 3 posts per page in the settings ?

  3. smartfinds
    Member
    Posted 9 months ago #

    Hi Tom,

    Well, now that I feel like a complete idiot! The only thing I could say in my defense is that in the code mentioned earlier there is the following 'numberposts' => 4, which would make you believe that the control for this was in the programming, so I spent time fussing with the code, database, etc and not even thinking of checking the obvious.

    Hopefully this will help someone else in the future that may purchase this particular theme we got.

    Thanks for putting is on the right path! :)

Reply

You must log in to post.

About this Topic