WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Show most recently updated pages (2 posts)

  1. electrifried
    Member
    Posted 6 years ago #

    Heyy...I was looking at the codex here and found out how to display pages according to the date/id but the thing I'm trying to do is limit it to showing the 5 latest ones - just like the recent posts tag:

    <?php
    $how_many=5; //How many posts do you want to show
    require_once('wp-config.php'); // Change this for your path to wp-config.php file ?>
    
    <ul class="main">
    <?
    $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code> FROM $wpdb->posts
    WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many");
    foreach($news as $np){
    printf ("<li><a href=\"index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title);
    }?>

    So I guess my question is...is it possible to display a list of recent pages like above (sorted with the latest to be updated at the top)?

  2. electrifried
    Member
    Posted 6 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic