Title: WP_Query Problem With Database
Last modified: August 20, 2016

---

# WP_Query Problem With Database

 *  [smartfinds](https://wordpress.org/support/users/smartfinds/)
 * (@smartfinds)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/wp_query-problem-with-database/)
 * 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.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Tom Lynch](https://wordpress.org/support/users/ctsttom/)
 * (@ctsttom)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/wp_query-problem-with-database/#post-2254969)
 * Are you sure your site isn’t setup with 3 posts per page in the settings ?
 *  Thread Starter [smartfinds](https://wordpress.org/support/users/smartfinds/)
 * (@smartfinds)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/wp_query-problem-with-database/#post-2254977)
 * 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! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WP_Query Problem With Database’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [database](https://wordpress.org/support/topic-tag/database/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [smartfinds](https://wordpress.org/support/users/smartfinds/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/wp_query-problem-with-database/#post-2254977)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
