WordPress.org

Support

Support » How-To and Troubleshooting » Check my code please

Check my code please

  • I’m trying to create headlines on the index page, one directory up from the blog. This code spits the format I want but it repeats it 3 times. So instead of the last 5 posts it shows 15 posts. Also I wondering what I need to show the content of the first latest post and just keep the other 4 just titles. Thanks!

    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    <?php $posts = get_posts(‘numberposts=5’); foreach ($posts as $post) { start_wp(); ?>
    <?php the_time(‘m.d.y’); ?> ~
    ” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_title(); ?>
    <br>
    <?php } ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Use this for what you’re after:

    <?php $posts = get_posts('numberposts=1'); foreach ($posts as $post) { start_wp(); ?>
    <?php the_time('m.d.y'); ?> ~
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a><br />
    <?php the_content(); ?>
    <?php } ?>

    <?php $posts = get_posts('offset=1&numberposts=4'); foreach ($posts as $post) { start_wp(); ?>
    <?php the_time('m.d.y'); ?> ~
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a><br />
    <?php } ?>

    That’s some nice work. Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Check my code please’ is closed to new replies.
Skip to toolbar