Skip Navigation

[Resolved] How to display the total amount of posts in search results parent layout?

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

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/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by frankK 6 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#1129679

I am cutomizing my archive layout for search results. The template has a parent layout. Inside there I want to display an information like: Your search term "documentation" was found on 16 posts. (I am using Relevanssi)

I am using [wpv-search-term] to display the search term. But how to display the total amount of the listet posts in search results? Is that possible?

I am looking forward to your anwer!

#1129894

Hi Frank,

Thank you for contacting us and I'll be happy to assist.

To show the total number of posts/search results, found by the View, you can use "[wpv-found-count]" shortcode:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-found-count

Note: remember to include it before the loop's start ( i.e. before <!-- wpv-loop-start --> tag ), in the "Loop Editor".

Please let me know if this helps.

regards,
Waqar

#1129949
parent-layout.png

Dear Waqar,
Thank you for your fast reply. I can solve my problem with your solution.

One more question to the same topic: Is there a way to display the result in the parent layout of my search result template? (screenshot)

#1130495

Hi Frank,

Thanks for writing back.

The shortcode [wpv-found-count] can be used within the "View" where the actual query has been processed, but not before that. This screenshot will further clear this up:
hidden link

In case, you'd like to show its value inside the layout, but outside the relevant view, a workaround is to use some JS script, to move it from one place to another.

For example, you can your shortcode inside the view, where it can be used inside a special span tag:


<span id="original-location">[wpv-found-count]</span>

Next, you'll add an empty span tag, in the layout where you'd actually like to show that value:


<span id="moved-location"></span>

In your View's "CSS editor", you can add following code to hide both these span tags, when the page loads:


span#original-location,
span#moved-location {
  display: none;
}

The actual script to move the value from the original location to the desired location can be added into the View's "JS editor":


$( document ).ready(function() {

  $("span#original-location").contents().appendTo("span#moved-location");
  $("span#moved-location").show();

});

For a more personalized and detailed assistance around custom code, you can consult, one of our certified consultants:
https://toolset.com/contractors/

#1130684

Thank you for your fast and detailed answer and solution! Perfect.

Toolset support rocks 🙂