I have a site which has 6 custom post types, each one has a search function to only search in that particular post type.
The search works as expected and displays the search results. Each custom post type also has some custom alphabetical pagination which also shows on search results pages, this viewing the custom post type archive, but when you then search from that archive, the search URL reverts back to root. For example :
mydomain.com/?s=Walsall&post_type=clubs
But to get my pagination working the search needs to retain its CPT slug like this :
mydomain.com/clubs/?s=Walsall&post_type=club_societies
Which should then display the desired results ( I think ? ).
This is the form Im currently using on each CPT archive page :
<div class="et_pb_search et_pb_module et_pb_bg_layout_light et_pb_text_align_left et_pb_search_0 clear">
<form role="search" action="<?php echo site_url('/'); ?>" method="get" class="et_pb_searchform">
<input type="search" class="et_pb_s" placeholder="<?php echo esc_attr_x( 'Search Clubs...', 'placeholder' ) ?>" value="<?php echo get_query_var('clubs'); ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" />
<input type="hidden" name="post_type" value="clubs" /> <!-- // hidden 'players' value -->
<input type="submit" class="et_pb_searchsubmit" alt="Search" value="Search" />
</form>
</div>
Any help appreciated.