Ready to get started?Download WordPress


First post different to second (6 posts)

  1. prb81
    Posted 2 years ago #

    I am looking for the first (most recent) post on my home page to appear different to the rest below it. I'd like for it to be a regular post with, say, a large centered image, and the rest to be an excerpt of the article with a smaller image.

    I understand to do this I need to post an excerpt with my posts but is there a way for the first post to ignore the excerpt?

    Hopefully this makes sense and thanks for anyone who can help.

  2. to do this I need to post an excerpt with my posts

    nope - you can do that, but the WordPress function the_excerpt() would otherwise automatically just show a few words of the post; http://codex.wordpress.org/Function_Reference/the_excerpt

    general structure in the loop i.e. after <?php while(have_posts()) : the_post(); ?>

    if($wp_query->current_post == 0 ) { ?>
    the way to show the first full post with image etc
    <?php } else { ?>
    the way to show the all other post with excerpt etc
    <?php }
  3. prb81
    Posted 2 years ago #

    Just to clarify. I currently have the follow to instruct my index page to display posts:

    <?php the_excerpt(); ?> <a>"> Read moreĀ»</a>

    Where would I put the code you mention in order for the first post to appear as a non-excerpt and the rest as the excerpt as instructed above?

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code has been permanently damaged/corrupted by the forum's parser.]

  4. there is likely to be more code in index.php - for instance there is usually a loop: see http://codex.wordpress.org/The_Loop

    feel free to post the code of index.php here - please use the pastebin as described in http://codex.wordpress.org/Forum_Welcome#Posting_Code

  5. prb81
    Posted 2 years ago #

    Yes there is more, just didn't want to past the whole thing, but here it is:


    [no bumping, please]

  6. for example:


    based on your exising code - you still need to clear up any unwanted output, and add the images - possibly using the_post_thumbnail()

Topic Closed

This topic has been closed to new replies.

About this Topic