Hi folks
I've used your article here https://toolset.com/documentation/user-guides/digging-into-view-outputs/ to set a featured post on the news archive which display differently to the rest of the posts. You can see it in action here:
lien caché
If you move to the second page of results (lien caché) the first post is featured here as well. I'd would like to adjust this so that the feature only displays on the first page of results and subsequent pages have just the three-column layout, is that possible?
This is how my loop looks:
<wpv-loop>
[wpv-item index=1]
<li class="col3">
[wpv-post-featured-image size="full"]
<div class="topcontent"><h2>[wpv-post-link]</h2>
[wpv-post-excerpt]
<p class="meta">[wpv-post-date] - [wpv-post-taxonomy type="category"]</p>
</div>
[wpv-item index=other]
<li class="col1">
[types field="one-column-image"][/types]
<h2>[wpv-post-link]</h2>
[wpv-post-excerpt]
<p class="meta">[wpv-post-date] - [wpv-post-taxonomy type="category"]</p>
</wpv-loop>
Many thanks, Emily
The Loop will iterate over each set of items that you have on each page.
If you have a code in your loop that features the first post, for example, this will run in each loop iteration and hence be the same logic on all pages.
What you can try is to use an HTML condition, in where you check the current page, and conditionally display featured code or just the standard grid.
Simplified, this looks like this:
<wpv-loop>
[wpv-item index=1]
[wpv-conditional if="( '[wpv-pager-current-page]' eq '1' )"]
This HTML is used if we are on the first page and first item
[/wpv-conditional]
[wpv-conditional if="( '[wpv-pager-current-page]' ne '1' )"]
This HTML is used for the first item on any other page
[/wpv-conditional]
[wpv-item index=other]
This HTML is used for all other items no matter the page
</wpv-loop>
You can read more about conditional HTML here:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
The ShortCode for the current page is explained here:
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153244
Thanks Beda, that works perfectly!
Thanks again, Emily