• Hello guys.

    I am struggling with an idea to display pages just like posts in a loop.

    I want to display latest pages with its custom fields. Is where any way to display pages in a loop showing latest 10 pages without childs?

    We do it with posts but can we do it with pages?

    Thank you.

Viewing 1 replies (of 1 total)
  • Thread Starter mikoleg

    (@mikoleg)

    I think i found one solution but not sure if its a good one and also i dont see a way to paginate it with that.

    <?php
    $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish' ORDER BY post_date DESC");
    if($pages) : foreach($pages as $post) : setup_postdata($post);
    ?>
    
    <?php endforeach; endif; ?>

    How do you think it could be managed the best, considering that we also need to limit the number of pages to display per page.

Viewing 1 replies (of 1 total)
  • The topic ‘How to display pages like posts in a loop? Is that possiable?’ is closed to new replies.