If you have done the first part correctly in loop-home.php
, you can just simply move that into the appropriate template used by your archive pages.
Taken into account that you have not used custom queries to build your queries on the homepage or any of the archive pages, you can do the following which will work on any of the aforementioned pages
-
Use the build in loop counter
$current_post
to count your posts. This counter starts at0
-
Target the first post with the counter and apply your styling to the first post only
Inside your loop, like in loop-home.php
do the following
if ( $wp_query->current_post === 0 ) {
// Do something to the first post
} else {
// Do something for all the other posts
}
If you only need to target the first post on the first page and not on the subsequent pages, just add !is_paged()
to your conditional statement. is_paged()
will check whether the current page is a paged page or not
if ( $wp_query->current_post === 0 && !is_paged() ) {
// Do something to the first post
} else {
// Do something for all the other posts
}