Title: get_the_content() within second loop doesn&#8217;t work correctly
Last modified: August 19, 2016

---

# get_the_content() within second loop doesn’t work correctly

 *  [wardrox](https://wordpress.org/support/users/wardrox/)
 * (@wardrox)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/get_the_content-within-second-loop-doesnt-work-correctly/)
 * I have a main loop and a plug-in which creates a second loop showing posts from
   a set category. Normally this works without error.
 * However, when the content within the _first_ loop is paged, and the user is looking
   at anything other than the very first page, `get_the_content()` returns the content
   from the first loop that has finished (specifically the data in the page being
   displayed), not the second loop which it is in.
 * Confusing things further, within the second loop the functions `the_title()` 
   and `get_permalink()` return data for the correct post.
 * Edit: An example of this error is [here](http://negativegamer.com/2009/10/07/gallery-fairytale-fights/2/).
   On the first page (and any other page on the site) the images (taken from a `
   get_the_content()` call) match the titles and articles. However on the second
   and beyond pages the images match that of the main loop’s.

Viewing 1 replies (of 1 total)

 *  Thread Starter [wardrox](https://wordpress.org/support/users/wardrox/)
 * (@wardrox)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/get_the_content-within-second-loop-doesnt-work-correctly/#post-1266859)
 * Fix:
 * Not sure which part of this fixes the problem but it seems to be working now.
   I changed the following;
 * Added the line:
    `global $id, $post, $more, $page, $pages, $multipage, $preview,
   $pagenow;`
 * Replaces `get_the_content()` with `$post->post_content;`
 * And moved where I call `$my_query->the_post();`
 * The original bug, whilst now circumvented, still exists.

Viewing 1 replies (of 1 total)

The topic ‘get_the_content() within second loop doesn’t work correctly’ is closed
to new replies.

## Tags

 * [get_the_content](https://wordpress.org/support/topic-tag/get_the_content/)
 * [the_title](https://wordpress.org/support/topic-tag/the_title/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [wardrox](https://wordpress.org/support/users/wardrox/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/get_the_content-within-second-loop-doesnt-work-correctly/#post-1266859)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
