• I would like to post an excert from the last 5 postings of a selected category.I use the following code but only get the first post.
    What have I missed?
    `?php
    $postlist = get_posts(‘category=15&numberposts=5’);
    foreach ($postlist as $post) ><?php the_excerpt(); ?>
    “>read more

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try:

    <?php
    $postlist = get_posts('category=15&numberposts=5');
    foreach ($postlist as $post):
     setup_postdata($post);
     the_excerpt();
    endforeach; ?>
    Thread Starter hawkesley

    (@hawkesley)

    Hi thanks for that. It worked fine.
    I amended it to show the title and a read more link.
    I would like to order the posts with oldest first not latest.
    Would you know if this can be done?
    Code at present
    `<?php
    $postlist = get_posts(‘category=15&numberposts=5’);
    foreach ($postlist as $post):
    setup_postdata($post);
    the_title();
    the_excerpt();
    ?>

    Try:

    $postlist = get_posts('category=15&numberposts=5&orderby=date&order=DESC');

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show excert from selected postings in a slected category’ is closed to new replies.