Title: get_item_quantity WordPress 2.9 error
Last modified: August 19, 2016

---

# get_item_quantity WordPress 2.9 error

 *  Resolved [tomleads](https://wordpress.org/support/users/tomleads/)
 * (@tomleads)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/get_item_quantity-wordpress-29-error/)
 * I had the following code working fine with 2.8
 *     ```
       <ul>
       <?php
       if(function_exists('fetch_feed')){
       	$uri = 'http://search.twitter.com/search?q=test';
       	$feed = fetch_feed($uri);
       	$maxitems = $feed->get_item_quantity(2);
       }
       ?>
       <?php
       //printf( $feed->get_title());
       foreach ($feed->get_items(0, $maxitems) as $item){
       $links = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link');
       $img = $links[1]['attribs']['']['href'];
       echo "<li>";
       printf('<a href="%s"><img alt="%s" src="'.$img.'" /></a>',$item->get_permalink(), $item->get_title());
       //printf('<h2><a href="%s">%s</a></h2>',$item->get_permalink(), $item->get_title());
       echo "<p>";
       printf('%s',$item->get_description());
       //printf('%s',$item->get_link());
       printf(' <strong>%s</strong>',$item->get_date('j F Y | g:i a'));
       echo "</p>";
       echo "</li>\n";
       }
       ?>
       </ul>
       ```
   
 * I upgraded to 2.9 and I get the following error:
 * >  Fatal error: Call to undefined method WP_Error::get_item_quantity() in domain\
   > wp-content\themes\mytheme\footer.php on line 14
 * Any ideas?

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

 *  [Ben Sutcliffe](https://wordpress.org/support/users/bsutcliffe/)
 * (@bsutcliffe)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/get_item_quantity-wordpress-29-error/#post-1324476)
 * Going by the [codex](http://codex.wordpress.org/Function_Reference/fetch_feed)
   your code is correct. Only thing is, is the `uri` specified valid? I would suggest
   that you should be referencing
    `twitter.com/search`**`.atom`**`?q=test` rather
   than `twitter.com/search?`.
 * It _could_ be that an invalid resource is returning an error when you come to
   run operations on the feed.
 *  Thread Starter [tomleads](https://wordpress.org/support/users/tomleads/)
 * (@tomleads)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/get_item_quantity-wordpress-29-error/#post-1324560)
 * Fantastic, that was the exact fix 🙂
 * Thanks
 *  [freshifreshy](https://wordpress.org/support/users/freshifreshy/)
 * (@freshifreshy)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/get_item_quantity-wordpress-29-error/#post-1324648)
 * I’m getting the same problem with a finicky rss feed. Is there a way I can skip
   the code if it returns an error?
 *  [freshifreshy](https://wordpress.org/support/users/freshifreshy/)
 * (@freshifreshy)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/get_item_quantity-wordpress-29-error/#post-1324649)
 * Figured it out.
 * If the feed you’re referencing is empty, simply check if the number of items 
   equals zero:
 * `if ($rss->get_item_quanity != 0) { run the code } else { run something else }`

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

The topic ‘get_item_quantity WordPress 2.9 error’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [freshifreshy](https://wordpress.org/support/users/freshifreshy/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/get_item_quantity-wordpress-29-error/#post-1324649)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
