• Resolved alexislevrai

    (@alexislevrai)


    Hello guys,

    I want to create different post design on the home page, something like :

    Post 1 & 2: Title / 240×150 image / Excerpt
    Post 3 : Title 500x 150 image / Excerpt / Categoy / Date
    Post 4,5,6,7,8,9 : Title 150×90 image / Title

    So my question is, how I can change php for each post number ?

    Thanks ?? Have a nice day.

Viewing 2 replies - 1 through 2 (of 2 total)
  • you could use a conditional statement in the loop of the home page template, checking the post’s position,
    possibly using $wp_query->current_post which is the counter for the posts in the loop (in a default query) (starting with 0)

    generally something like:

    <?php if( $wp_query->current_post <= 1 && !is_paged() ) : ?>
    OUTPUT FOR POST 1 & 2, Title / 240x150 image / Excerpt
    <?php elseif( $wp_query->current_post == 2 && !is_paged() ) : ?>
    OUTPUT FOR POST 3, Title 500x 150 image / Excerpt / Categoy / Date
    <?php else : ?>
    OUTPUT FOR all other POSTS, Title 150x90 image / Title
    <?php endif; ?>

    remove && !is_paged() if you want the same structure on paginated pages.

    Thread Starter alexislevrai

    (@alexislevrai)

    Oh yes it works perfect !
    Thanks you ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple post design homepage’ is closed to new replies.