WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to show last updated pages (6 posts)

  1. Martin777
    Member
    Posted 1 year ago #

    Dear friends,
    I would like to display last updated pages in my sidebar.
    I am totally newbie in the php world, but I found a tuned a code from a forum:

    <?php
       $args=array(
       'showposts'=>10,
       'post_type' => 'page',
       'caller_get_posts'=>1,
       'cat' => 206, 191, 184, 185, 186, 187, 188, 189, 190
       );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><small><?php the_time('d.m.y') ?></small> <a href="<?php the_permalink() ?>" rel="bookmark" title="Odkaz na <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    }
    ?>

    The code works pretty well, just it shows new added pages exclusively, not all updated pages:-(

    What is needed to be changed there to show all last updated pages?

    Thanks a lot,
    Martin

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    Assuming you mean Posts, try:

    <?php
    $args=array(
       'posts_per_page'=>10,
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><small><?php the_time('d.m.y') ?></small> <a href="<?php the_permalink() ?>" rel="bookmark" title="Odkaz na <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    }
    ?>
  3. Roy
    Member
    Posted 1 year ago #

  4. Martin777
    Member
    Posted 1 year ago #

    @esmi,
    I mean Pages. My adapted code works great, but the list contains new added pages exclusively and I need to include also updates of my Pages.
    Thanks a lot,
    Martin

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    Try changing:

    $args=array(
       'posts_per_page'=>10,
    );

    to:

    $args=array(
       'posts_per_page'=>10,
       'post_type' => 'page'
    );
  6. Martin777
    Member
    Posted 1 year ago #

    @esmi,
    I have just found an error in my code:

    <?php
       'cat' => 206, 191, 184, 185, 186, 187, 188, 189, 190
       );

    I created a new parent category 213, which includes all my original categories and the original code works now:-)

    Thanks a lot for your help.

    Martin

Topic Closed

This topic has been closed to new replies.

About this Topic