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.
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.
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.
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.
My issue is resolved now. Thank you!