[resolved] More tag ignored when displaying sub pages (5 posts)

  1. hannuok
    Posted 6 years ago #

    I'm reposting this from another forum.

    I know other people have had a similar problem and I've browsed through the forum and Codex, but I haven't been able to solve this problem.

    I'm showing sub pages on top level pages using get_pages:

        $pages = get_pages('child_of='.$post->ID.'&sort_column=menu_order&sort_order=asc');
        $count = 0;
        foreach($pages as $page) {
            $content = $page->post_content;
            $content = apply_filters('the_content', $content);
            $content = str_replace(']]>', ']]>', $content);
            <div id="<?php echo $page->post_name ?>" class="page">
                <h3 class="post-title"><?php echo $page->post_title ?></h3>
                <div class="post-body">
                    <?php echo $content ?>
    <?php } ?>

    The problem is that <!--more--> gets ignored. I know of the proposed solution mentioned here, but it doesn't work for me. I've tried to add the snippet in every part of the code, before the loop, inside the loop, you name it.

    The more tag is just displayed as paragraph: <p><!--more--></p>

    Many of the people that had similar problems weren't using get_pages so I'm thinking the problem is somewhere there (or how the main content is defined inside a single page of loop).

    Any help? Deadline is approaching and I've hit a wall with this. Thank you!

  2. MichaelH
    Posted 6 years ago #

  3. hannuok
    Posted 6 years ago #

    Sorry, my post had messed up. The word "here" was supposed to contain a link to that exact Codex post.

    Is that solution supposed to work with get_pages? I've tried to put that snippet of code to pretty much every part of the loop, and it doesn't work.

  4. MichaelH
    Posted 6 years ago #

    This example works:

      'post_parent' => 93,
      'orderby'=> 'menu_order',
      'post_type' => 'page',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of Posts';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        global $more;
        $more = 0;
    wp_reset_query();  // Restore global post data stomped by the_post().
  5. hannuok
    Posted 6 years ago #

    Thank you!! I had thought if using WP_Querywould solve this, but get_pages is just somehow so much simpler to use that I always utilized it instead.

Topic Closed

This topic has been closed to new replies.

About this Topic