Skip Navigation

[Resolved] how to show search results on archive?

This support ticket is created 5 years, 4 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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Joe H. 5 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1323993

Tell us what you are trying to do?

I've built a View of Speakers ( slug = "speakers") and have the search form appearing on the home page but not the results. I want the results to appear on the archive of the CPT /speaker. The idea is that the archive shows either all results of the search form (i.e. when no parameters chosen by the user), or it shows partial/filtered results based on parameters chosen by user (chosen from any place the search form appears on the site).

I can create a custom archive that displays both the search form and its results but when I attempt to insert the View (search only) on the homepage or anywhere else, Toolset forces me to choose a Page for the search results. I can't select the archive.

I also can't create a Page using the same slug as the archive. So how is this typically done?

This site is a perfect example of what I want to do, and is even using Toolset, but I dont see how they are doing this:

hidden link <-- search form just below main nav takes you to
/speakers.php?n=&f=one&t=0&wpv_post_search=&wpv_filter_submit=Search

hidden link <-- notice this is a Page and not an Archive, and yet it has same slug as the CPT.

#1324129

Hello,

It is expected result, you can not use same slug in both a wordpress page and a post type.

As a workaround, you can use custom JS codes to change the attribute "action" of HTML form tag.

For example, edit your post view(ID: 6663), in section "Search and Pagination", click "JS Editor", add below JS codes:

jQuery('form[data-viewid="6663"]').attr('action', "<em><u>hidden link</u></em>");

Please replace hidden link with the "speaker" post type archive page URL.

#1324673

I understand that I can't use the same slug in both a wordpress page and a post type. So my question remains: how is this site (which is not mine, but is a Toolset site) apparently achieving this exact thing?

1. When the Toolset Search View is used from the home page, the results open in /speaker....

2. On this site /speaker is a WordPress Page and not an Archive of the Toolset CPT

3. /speaker is also the slug for the Toolset CPT.

I attempted your workaround on my site and it did not work. I am hoping that by looking at hidden link you can discern how they are achieving this, as I would like to recreate this behavior on my site.

#1324781

As you see, that website is using a PHP file "speakers.php" to render the view's result, I don't think it is a good idea.

I have tested above JS codes in my localhost, it works fine.

And you will need to replace 6663 with your view's ID.

If you still need more assistance for it, please provide a test site with the same problem, I can setup a demo for you.

#1329063

My issue is resolved now. Thank you!