Forums

Creating a Loop of Pages (3 posts)

  1. dancameron
    Member
    Posted 1 year ago #

    I just can't figure this one out.

    Is it possible to create a loop of pages? I need to create a "page" that displays sub pages, like a category page would for posts.

    Is this even possible? Anyone build a plugin to accomplish this?

    I'm not interested in manually querying each post in the template page, it needs to be dynamic.

    Thanks in advance.

  2. MichaelH
    moderator
    Posted 1 year ago #

    Use this with a loop in a page template:

    $myquery = WP_Query('post_type=page')

  3. dancameron
    Member
    Posted 1 year ago #

    Thanks MichaelH,

    I ended up going a different using a custom select query.

    <?php

    $querystr = "
    SELECT wposts.*
    FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
    WHERE wposts.ID = wpostmeta.post_id
    AND wpostmeta.meta_key = 'repertory'
    AND wposts.post_type = 'page'
    ORDER BY wpostmeta.meta_value DESC
    ";

    $pageposts = $wpdb->get_results($querystr, OBJECT);

    ?>
    <?php if ($pageposts): ?>
    <?php foreach ($pageposts as $post): ?>
    <?php setup_postdata($post); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic