Skip Navigation

[Resolved] create a cpt search result page

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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 6 replies, has 2 voices.

Last updated by Nigel 5 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#1169480

Jim

I want to create a search results page for a custpom post type.

I created a wordpress archive for that post type and embnedded that into the archive page layout for that cpt but that results in the warning "A WordPress Archive page should be used to display this layout." (but I thought i just created that..?)

I also created a view but that just results in a list off all the cpt posts, not search results.
Also, when I manually add search querystring to the url I get a 404 page not found.

Can anyone help me find the missing link?

Thanks

#1169492

Jim

As a sidenote:
please make the login sessions here on your site longer. I created this support ticket very detailed and to do so it took a long time to be very clear about what I did/wanted and the results. Then finally submitted my ticket and my login session was over and my ticket not submitted. I had to start over...! (which I did but not as detailed...)

I have had this before. Very frustrating...

#1169883

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Jim

I've shared your feedback about the forum sessions, sorry for the inconvenience.

Regarding archives.

First, let's forget about Layouts for one moment.

You can create a custom archive at Toolset > WordPress Archives. You'll find the interface much like that for creating a View, and it can include custom search filters.

If you assign that custom archive to a post type then it will be used when you visit the URL of the archive on the front end.

Now, bring Layouts into the mix.

You can create a new Template Layout at Toolset > Layouts and assign it to the same archive.

If you still have a custom archive made with Views assigned to the archive, Layouts will win, it will take control of the output of the archive page.

But what will it show?

Whatever you include in the cells of the template.

The WordPress Archive cell is a special cell that is the same as the custom archive you could create directly at Toolset > WordPress Archives, it is the bit that actually returns the matching posts and loops over them.

When you insert such a cell, you can either choose an existing custom archive you already made directly, or you can make a new one from within Layouts.

If you were starting from scratch with Layouts to make a custom archive for the Projects post type, for example, you might go to Toolset > Layouts and create a new Layout which you assign to the Projects archive. You insert some cells, one of which must be the WordPress Archive cell. You create a new custom archive, specifying that you want it to include custom search, so that you can add filter controls.

Is that clear?

#1170433

Jim

Hi Nigel,
It's possibly not that difficult but still hard to understand...

- I created a Toolset 'wordpress archive' with searchresults and my cpt selected:
hidden link

- I created an 'archive page layout' for this cpt and included the 'Toolset wordpress archive' .
hidden link

- I created a the post type archive page and assigned the cpt archive layout
hidden link

But the result is "A WordPress Archive page should be used to display this layout.":
hidden link

---------------------

Also, what I need is not an archive but search results! Or does that not matter?

The thing is that when I point the search form to my search result page I get a 404 page not found. Somehow the query string is not recognised as such and is looking for a page...

hidden link

It is probably very simple but I need some more help to understand.

Thanks

#1170484

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screenshot 2018-12-20 at 11.48.00.png

"I created a the post type archive page and assigned the cpt archive layout"

No. You create a Template Layout and assign it to the archive in question, you do not create a static WordPress page and use the archive Layout for that page.

Archives are a special WordPress concept to display lists of posts, which are displayed at particular URLs.

The blog is a special case, which displays the archive of standard Posts.

If you have a custom post type of Projects then its archive would be displayed at the URL site.com/project/

When you come to set the use of a Layout you will notice that WordPress has certain special archives in addition to the archives of custom posts. Search results is a special archive page.

If you only want to customise the standard WordPress search archive, then when you set the usage for the Layout you create you should only specify the search archive (in your screenshots you seem to be mixing up using a custom archive Layout for post type archives and the search archive, but it sounds like that is not your intent).

So if you create a Layout which you assign to the search archive, this is what will be used when displaying the results of standard searches on the front-end. When editing the archive cell that this Layout includes, for the search results you are able to specify which post types should be included in the search results (screenshot).

#1170617

Jim

Hi Nigel,

Not sure if I can follow all you said.

My purpose is to get the search results (for just one cpt) on a certain page that I choose.
Is it not possible to get search results on another page then the archive page for that cpt?

So, I have my normal site search and the page for those results is the root of the website.
I have build a glossery with a cpt and want to allow visitors to search through it and display the results on a page within this glossary part of the site.

As part of that I want to display the search results styled a certain way (like I have in the archive loop).

Is this possible. And if so, what steps do I need to take?

#1170637

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

"Is it not possible to get search results on another page then the archive page for that cpt?"

They are separate things. There is an archive for a custom post type (e.g. site.com/project/ would display the archive of the Projects post type). And there is the search archive, a special WordPress archive to show results from a standard WordPress search, (normally) invoked by the 's' URL parameter, e.g. site.com/?s=chevrolet.

You can customise the standard search archive (as we have been discussing above), including customising which post types are included in the results. There is only one WordPress search archive, so a custom search archive would affect all such searches.

A theme would typically include a search box in the header or main navigation which uses this standard search archive.

Now, you can create a custom search with Views which has nothing to do with archives, and specifically the search archive, and I think this is what you want.

So, go to Toolset > Views and create a View for the post type in question (glossaries), specifying that this will be a custom search View.

In the Search and Pagination section insert a text search control and a submit button.

Then design the output much like I think you already did when you were experimenting with archives.

Now go to the page where you want this search to appear and insert the View directly in the page (using the Fields and Views button).

Visit this page on the front end and you should see a text search input where users can enter their search terms.

Note that this would normally search the title and post content of the glossary posts. If you have content in custom fields that you want included in the search, you would need to add the Relevanssi plugin and set it up according to https://toolset.com/documentation/user-guides/searching-texts-custom-fields-views-relevanssi/.

Any outstanding questions, please ask away.

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