Archived topic
Separate search archive for custom post type category
3 replies · Started by George on May 1, 2018
I am displaying a custom post type category archive on my homepage and have targeted certain css classes to act only on the category archive, like making te archive max-width: 100%, etc. When I initiate a search though, the search reults page goes back to the default search archive layout. I would like to keep that layout for the normal blog search but would like to have another search archive only for the homepage that resembles the moficiations I have made for the particular custom post type category archive. Is that even possible? I hope I make sense!
Hi George,
I'm not too sure what you mean.
Are you wanting to set the search results container to 100%? But only if your CPT items are within the search results?
Never thought about it like that but essentially yes.
Basically, I am using Relevanssi to enhance my search. They have a functionality where I can display a shortcode anywhere else on the page and that search input box can limit the search results to a certain custom post type. So I am restricting results to a certain custom post type from the homepage where I also have a category archive displaying a blog grid with items from that custom post type. I have made some CSS changes to that grid, including setting the page to 100%, removing some post meta, etc. Finally I am hiding the site-wide search from the homepage only.
When I search with the restricted search box, the layout search results change the layout. That's because on the homepage grid, I target the .category selector but when the search arhive gets displayed, that selector is obviously gone. The thing is that I would like to keep the search archive as it is while searching with the sitewide search but only keep the changes I made to the grid on the homepage's search results.
In that case, you would need to add a body class depending on the CPT being searched by Relevanssi.
Might be worth asking them if something like that is possible - they might have a conditional.