• Resolved slee

    (@slee)


    does anyone know how to output a list of child pages of a particular parent but order them by certain metadata?

Viewing 8 replies - 1 through 8 (of 8 total)
  • This might work…didn’t test though

    <?php
    $args=array(
      'showposts' => -1,
      'post_type' => 'page',
      'post_parent' => 93,
      'meta_key' => 'your_custom_field_here',
      'orderby' => 'meta_value'
    );
    $pages = get_posts($args);
    if ($pages) {
      foreach($pages as $post) {
        setup_postdata($post); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      } // foreach($pages
    } // if ($pages
    ?>

    Thread Starter slee

    (@slee)

    that is great thanks yes it worked first time ??

    Thread Starter slee

    (@slee)

    if i wanted to use this but page the output how would i go about doing that?

    Thread Starter slee

    (@slee)

    thanks ill shall have a look. is there any way of doing what you first gave me using the args method to use query_posts instead even though it is for pages?

    Thread Starter slee

    (@slee)

    i managed to figure it out and ive got the paging working which is great i do have one final question. with the above code you have given will that also output children/children ? i only want it to output pages with the parent id of 116 so hopefully it won’t output the children/children.

    It was pretty easy to go back and create a grandchild page to test this–and no it didn’t include that grandchild page.

    Thread Starter slee

    (@slee)

    brilliant thanks for the help it is very much appreciated.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Output a list of child pages of a particular parent ordered by custom field’ is closed to new replies.