Forums

Sub-level pages only in custom query (1 post)

  1. Christian Westerink
    Member
    Posted 6 months ago #

    Hello,

    I am using a custom query to get te latest updated pages. Problem is,however, it also includes parent pages. I would like it only displays the lowest-level pages (with no children). How to?

    The code:

    <?php
    $today = current_time('mysql', 1);
    $howMany = 8; //Number of posts you want to display
    if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT $howMany")):
    ?>
    			<?php
    foreach ($recentposts as $post) {
    if ($post->post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID);?>

    The website: http://www.scheepvaartinbeeld.nl/
    The code runs the Updates and Nieuwste schepen on the homepage.

Reply

You must log in to post.

About this Topic

  • RSS feed for this topic
  • Started 6 months ago by Christian Westerink
  • This topic is not resolved
  • WordPress version: 3.2.1