Forums

Show last X Post Titles in Blog Post? (6 posts)

  1. aeropause
    Member
    Posted 3 years ago #

    I do a weekly "This week in news" and every time I have to copy/paste each title and link into a blog post.

    Does anyone know how to show the last X number of post titles with links in a blog post?

    I found this in the codex, but it just ouputs the PHP code:

    <?php
     $postslist = get_posts('numberposts=10&order=ASC&orderby=post_title');
     foreach ($postslist as $post) :
        setup_postdata($post);
     ?>
     <div>
     <?php the_date(); ?>
     <br />
     <?php the_title(); ?>
     <?php the_excerpt(); ?>
     </div>
     <?php endforeach; ?>

    Thanks a lot
    shane

  2. Stefanie
    Member
    Posted 3 years ago #

    Try this:

    <ul> <?php wp_get_archives('type=postbypost&limit=10'); ?> </ul>

    Change 10 to whatever number of posts you want.

  3. aeropause
    Member
    Posted 3 years ago #

    Hey thanks for the reply. It didn't output anything though, just a blank screen :-(

  4. Stefanie
    Member
    Posted 3 years ago #

    If you're putting it into a post, you're going to need a plugin to execute php in posts. Exec-PHP is one.

  5. aeropause
    Member
    Posted 3 years ago #

    Oh awesome thanks a lot!

  6. aeropause
    Member
    Posted 3 years ago #

    well I got the plugin installed, published the post with that code you specified, but still nothing :-(

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.