WordPress.org

Ready to get started?Download WordPress

Forums

link to most current page (4 posts)

  1. maestro42
    Member
    Posted 5 years ago #

    i have a link on the homepage that goes to a page that i create monthly. each month a new page is created - and when you visit that page - it uses wp_list_pages to show all the previous month's pages (like an archive).

    I want to have this link on the homepage always link to the most current page posted. but i have to keep changing the HTML link each time i post a new page.

    is there any way to call only the most currently posted page? i tried using wp_list_pages but could not get it work because it calls all pages.

    thanks

  2. dlhuett330
    Member
    Posted 5 years ago #

    Did you ever figure this one out? I am having this problem also, but on a daily basis.

    Thanks

  3. Kevin Kwok
    Member
    Posted 4 years ago #

    i am also looking for this solution..
    and exactly what dilhuett is looking for

  4. MichaelH
    Member
    Posted 4 years ago #

    <?php
    wp_list_pages('sort_column=post_date&sort_order=DESC&number=1');
    ?>

    or

    <?php
      $args=array(
        'post_type' => 'page',
        'post_status' => 'publish',
        'orderby' => 'date',
        'order' => 'DESC',
        'showposts' => 1,
        'caller_get_posts'=> 1
        );
      $my_query = null;
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        echo 'List of: ' . $type .'(s)';
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
         <?php
        endwhile;
      } //if ($my_query)
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.