Title: the_content with setup_postdata
Last modified: August 19, 2016

---

# the_content with setup_postdata

 *  Resolved [der_ele](https://wordpress.org/support/users/der_ele/)
 * (@der_ele)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/the_content-with-setup_postdata/)
 * Hello!
    I have the following problem: The “read more..” is not shown on my custom
   page, but on the index.php. Here my code:
 *     ```
       <?php
       /**
        * @package WordPress
        * @subpackage Default_Theme
        * Template Name: Aktuelles
       */
       global $more;
   
       $cat= 3;
       $posts = get_posts ("cat=$cat&showposts=5");
         if ($posts) {
           foreach ($posts as $post):
       	$more = false;
       	setup_postdata($post);
              ?>
       	<h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
       	<p class="storycontent"><?php the_content('Read more...'); ?></p>
           <?php
       	endforeach;
           $more = true;
         }
   
       ?>
       ```
   
 * Thanks in advance der_ele

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/the_content-with-setup_postdata/#post-1393137)
 *     ```
       <?php
       /**
        * @package WordPress
        * @subpackage Default_Theme
        * Template Name: Aktuelles
       */
   
       $cat= 1;
       $posts = get_posts ("cat=$cat&showposts=5");
         if ($posts) {
           foreach ($posts as $post):
       	$more = false;
       	setup_postdata($post);
              global $more;
              $more = false;?>
       	<h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
       	<p class="storycontent"><?php the_content('Read more...'); ?></p>
           <?php
       	endforeach;
           $more = true;
         }
   
       ?>
       ```
   
 *  Thread Starter [der_ele](https://wordpress.org/support/users/der_ele/)
 * (@der_ele)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/the_content-with-setup_postdata/#post-1393283)
 * Thanks working perfect!
 *  [pironic](https://wordpress.org/support/users/pironic/)
 * (@pironic)
 * [16 years ago](https://wordpress.org/support/topic/the_content-with-setup_postdata/#post-1393499)
 * prefect this worked for me too… its just a problem with the $more variable eh?
 * I had this:
    foreach ($postslist as $post) : setup_postdata($post);
 * and added:
    global $more; $more = false; immediately following to fix my code.
   Thanks for the help MichaelH!
 *  [pironic](https://wordpress.org/support/users/pironic/)
 * (@pironic)
 * [16 years ago](https://wordpress.org/support/topic/the_content-with-setup_postdata/#post-1393500)
 * –deleted duplicate post–
 *  [palbrattberg](https://wordpress.org/support/users/palbrattberg/)
 * (@palbrattberg)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/the_content-with-setup_postdata/#post-1393514)
 * That is one weird hack. Worked, but seems like a bug, no?

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

The topic ‘the_content with setup_postdata’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 4 participants
 * Last reply from: [palbrattberg](https://wordpress.org/support/users/palbrattberg/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/the_content-with-setup_postdata/#post-1393514)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
