Skip Navigation

[Resolved] Feature post to display only on first page

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by emilyT 5 years, 11 months ago.

Author
Posts
#876324

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:
hidden link

If you move to the second page of results (hidden link) 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">
<a href="[wpv-post-url]">[wpv-post-featured-image size="full"]</a>
<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">
<a href="[wpv-post-url]">[types field="one-column-image"][/types]</a>
<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

#878817

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

#889454

Thanks Beda, that works perfectly!

Thanks again, Emily

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.