Title: Keep Getting Member Function Error
Last modified: August 20, 2016

---

# Keep Getting Member Function Error

 *  Resolved [Jacob Martella](https://wordpress.org/support/users/arenapigskin/)
 * (@arenapigskin)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/keep-getting-member-function-error/)
 * I’m creating my first theme with all of the files needed completed. My home.php
   features a featured post slideshow that I got [here](http://legendthemes.com/2010/06/14/building-a-jquery-posts-slider-wordpress/).
   I copied the code word-for-word (see below), but I keep getting the following
   error: Fatal error: Call to a member function have_posts() on a non-object in
   C:\xampp\htdocs\wordpress\wp-content\themes\sports\home.php on line 21.
 *     ```
       <?php
       		$featuredposts = new WP_Query();
       		$featuredposts->query("showposts=4&cat=5");
       		while ($featuredposts->have_posts()) : $featuredposts->the_post();
       	?>
       ```
   
 * I can’t find any solution for my problem. Any help?

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

 *  Thread Starter [Jacob Martella](https://wordpress.org/support/users/arenapigskin/)
 * (@arenapigskin)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/keep-getting-member-function-error/#post-2801323)
 * Hold on, never mind. I realized I made an error later on down where I tried to
   call the variable and I had an incorrect capitalized letter. That being said,
   I now get the following error: Fatal error: Call to undefined method WP_Query::
   the_posts() in C:\xampp\htdocs\wordpress\wp-content\themes\sports\home.php on
   line 21.
 * Any help on that.
 *  [Jarret](https://wordpress.org/support/users/jarretc/)
 * (@jarretc)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/keep-getting-member-function-error/#post-2801333)
 * What does line 21 on home.php look like along with the code for a few lines above
   it?
 *  Thread Starter [Jacob Martella](https://wordpress.org/support/users/arenapigskin/)
 * (@arenapigskin)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/keep-getting-member-function-error/#post-2801394)
 * Yeah, sorry about that. Thought of it after I shut down last night.
 * Here is line 21:
    `($featuredposts->have_posts()) : $featuredposts->the_posts();`
 * Here is the entire code for slideshow:
 *     ```
       <?php
       		$featuredposts = new WP_Query();
       		$featuredposts->query("showposts=4&cat=5");
       		while ($featuredposts->have_posts()) : $featuredposts->the_post();
       	?>
   
       	<div id="slide-<?php echo $slide_id; $slide_id++;?>">
       		<a href="<?php the_permalink() ?>">
       		<?php the_post_thumbnail( 'slideshow-photo' ); ?>
       		</a>
       	</div>
   
       	<?php endwhile; ?>
   
       	<ul id="slide-nav">
       		<?php $nav_id=1; while
       		($featuredposts->have_posts()) : $featuredposts->the_posts(); ?>
       			<li>
       				<a href="#slide-<?php echo $nav_id; ?>">
       					<span>
       						<?php the_post_thumbnail( 'nav-image' ); ?>
       					</span>
       					<?php the_title(); $nav_id++;?>
       				</a>
       			</li>
       		<?php endwhile; ?>
       ```
   
 *  Thread Starter [Jacob Martella](https://wordpress.org/support/users/arenapigskin/)
 * (@arenapigskin)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/keep-getting-member-function-error/#post-2801413)
 * Okay, so kept looking at the code and I figured out the problem. The second the_post()
   statement had an ‘s’ at the end of it (result: the_posts() ). So I’m not getting
   the error anymore; however, the slideshow isn’t working (see [this link](http://greatusrailfan.byethost6.com/wp-content/uploads/2012/06/Sports-Theme-Test-Site-screenshot.png)).
   The tutorial says to use wp_enqueue_scripts() to get the ‘jquery’, ‘jquery-ui-
   core’ and ‘jquery-ui-tabs’ files. Not sure why it’s not working.
 * And finally, my CSS skills are a bit on the bad side, obviously. If anyone wishes
   to help me, message me and I’ll see if I can get you the files as soon as possible.
   Thanks in advance.

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

The topic ‘Keep Getting Member Function Error’ is closed to new replies.

## Tags

 * [have_posts()](https://wordpress.org/support/topic-tag/have_posts/)
 * [non object](https://wordpress.org/support/topic-tag/non-object/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [Jacob Martella](https://wordpress.org/support/users/arenapigskin/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/keep-getting-member-function-error/#post-2801413)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
