Forums

[resolved] How to put auto-sitemap on Page? (4 posts)

  1. chris-melchior
    Member
    Posted 2 years ago #

    Is is possible to get an automatically updating sitemap, (listing of Posts), on one Page only? I don't want "latest posts" or "archives" on all pages or posts, but only on one Page only, can I do that, or is there another way to get such a site-map onto a single Page?

    thanks :)

    Chris

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    This in a Page Template will work:

    <?php
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of All Posts';
      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;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
  3. chris-melchior
    Member
    Posted 2 years ago #

    Thanks very much, will try that soon :)

    Chris

  4. chris-melchior
    Member
    Posted 2 years ago #

    That works well, thanks!

    Chris

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags