Title: strange the_content error
Last modified: August 19, 2016

---

# strange the_content error

 *  [jhodgson](https://wordpress.org/support/users/jhodgson/)
 * (@jhodgson)
 * [17 years ago](https://wordpress.org/support/topic/strange-the_content-error/)
 * I’m trying to list posts in a category like so:
 *     ```
       <?php
       global $post;
       $myposts = get_posts('numberposts=2&amp;category=3');
       foreach($myposts as $post) :
       ?>
       <div class="articles"><a href="<?php the_permalink(); ?>"><?php the_content('more'); ?></a></div>
       <?php endforeach; ?>
       ```
   
 * But I get these errors:
 * Warning: preg_match() expects parameter 2 to be string, object given in dir/wp-
   includes/post-template.php on line 202
 * Catchable fatal error: Object of class stdClass could not be converted to string
   in dir/wp-includes/post-template.php on line 214
 * if I change “the_content(‘more’)” to “the_title()” it works fine, but I want 
   the content, not the title.
 * What’s going on here and how can I fix it?
 * Thanks!

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years ago](https://wordpress.org/support/topic/strange-the_content-error/#post-1062137)
 * Don’t think you need the global statement
    Use `setup_postdata($post);` after
   your `foreach` statement
 * Don’t see what causes the error.

Viewing 1 replies (of 1 total)

The topic ‘strange the_content error’ is closed to new replies.

 * 1 reply
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/strange-the_content-error/#post-1062137)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
