Skip Navigation

[Resolved] Best way to intelligently display a "more results" button?

This support ticket is created 7 years, 1 month 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 3 voices.

Last updated by Bob 7 years, 1 month ago.

Assigned support staff: Luo Yang.

Author
Posts
#388498

I have a view that shows the latest 4 posts by an author, using a limit of 4 posts.

Beneath the 4 posts, I have a link that says, "click here for more posts" which leads to a page where an unlimited (infinite scroller) list of the author's posts appear.

All this works fine.

My question is this: How do I make a conditional so that the "click here for more posts" link only shows up if the author has more than 4 posts available?

I'm stuck because I can't rely on [wpv-post-count] -- because that will always be 4 even if the author has 1,000 posts since I've limited the query to showing just 4.

Thanks for any suggestions. I might be thinking about this the wrong way.

#389221

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Dear canton,

How do you setup the "click here for more posts" link?
If you use the build-in feature infinite-scrolling of Views plugin, you will need to setup the option "Limit and Offset" as "No limit", and follow our document:
Infinite Scrolling for WordPress Content
https://toolset.com/documentation/user-guides/infinite-scrolling-in-views/

#389613

Sorry, I don't think my question was well expressed (or well understood).

I already know how to do infinite views.

My question is when I have a non-infinite view that only shows 4 items, what's a display option or a conditional that will allow me work with the total number of items that *could* have been displayed, had I not set a limit?

My page currently shows only the first 4 items.

I want to make a conditional that shows a "More" link (and links out to a totally different view I've made) only if more than 4 items are *possible* given all the other filters that have been set besides the limit.

Does that make sense?

#389840

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

I assume you have already setup the option "Limit and Offset" in view as "shows 4 items", so the shortcode [wpv-items-count] will not be able to return more than 4 value:
https://toolset.com/documentation/views-shortcodes/#wpv-items-count

So it is not possible within Views, as a workaround you can create a custom shortcode to output posts count of the specific author, then use Views shortcode [wpv-conditional] to check the result of above view, if the result is above 4, then display the "click here for more posts" link:
https://toolset.com/documentation/views-shortcodes/#wpv-conditional
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
section "Setting up conditions manually"

#389901

Bob

How about setting query limit = 5 and pagination = 4 and then add a [wpv-conditional ...] after the [wpv-layout-meta-html] which has whatever action/code you want to do when found-count is > 4?

[wpv-filter-meta-html]
[wpv-layout-meta-html]
[wpv-conditional if="( '[wpv-found-count]' gt '4' )"]More Posts action goes here[/wpv-conditional]

Cheers,

Bob

#390104

Wow, it looks like I have two options here, yours and Bob's.

I think I'll try Bob's first -- that makes a lot of sense. Thanks Bob!

Luo, just to makes sure I understand your solution which sounds like a generally interesting way around problems:

I can create a view whose ONLY output is merely the [wpv-found-count] of some query, and then in my main view, I invoke that other view within a conditional. Is that right?

#390116

Bob's solution works *great*! See:

hidden link
vs.
hidden link

Thanks!

#390149

Bob

No problem.
Glad that helped you out.

Cheers,

Bob