This is a question based on the comments from the answer here.
I'm using the following code to create a couple of different search boxes for my website:
<form action="<?php echo home_url( '/glossary/' ); ?>" method="get">
<p style="font-size:12px;">SEARCH<strong class="dkblue">GLOSSARY</strong></p>
<input type="text" name="s" value="" />
<input type="submit" value="GO" class="glossary_submit" />
</form>
<form id="profilesearch" action="<?php echo home_url( '/species/' ); ?>" method="get">
<input type="text" size="50" class="default-value" value="SEARCH" name="s" />
<input type="submit" value="GO" class="profilesearch_submit" />
<!-- <p class="tinysearch"><a href="/dev/advanced-search/">ADVANCED SEARCH</a></p> -->
<input type="checkbox" name="showthumbnails" id="showthumbnails" class="checkbox" <?php if ($_POST["showthumbnails"] == "on") { echo 'checked="checked" '; } ?>/><label for="showthumbnails">HIDE THUMBNAILS</label>
</form>
My glossary CPT has the following creation $args:
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => true,
'menu_position' => 40,
'menu_icon' => $this->plugin_url . 'images/glossary.png',
'supports' => array('title','editor','thumbnail','page-attributes')
);
And my species CPT has these:
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'has_archive' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 5,
'menu_icon' => $this->plugin_url . 'images/fish20.png',
'supports' => array('author','thumbnail','excerpt','comments','revisions')
);
Currently, when I submit a search from the glossary form, the URL changes to: /glossary/?s=term. When I submit a search from the species form, the URL changes to: /search/term.
The glossary URL does what it's meant to do - searches for glossary CPT types only. The species URL however simply searches for everything.
If I change has_archive to false, the searches work as per the above glossary. If I change it to true, the searches work as per the above species.
What I want both to do is this: change URL to /search/cpt-slug/term, i.e. /search/species/bettas and search for only posts with that CPT.
Have I done something wrong with my $args?