IMPORTANT UPDATE: I’ve realised that my problems could also lie with the WordPress 3.3 update.
A while ago I posted a solution to my own question about searching Custom Post Types.
At that time, I was using the URL http://www.seriouslyfish.com/dev/
whilst I redeveloped the website.
Now I’ve “gone live” and moved everything over to http://www.seriouslyfish.com
.
For some reason, this appears to have broken my Custom Post Type searches. If you try searching from the “PROFILESEARCH” or “QUESTIONSEARCH” boxes, you’ll see that it’s redirecting to /search/
rather than /questions/search
or /species/search
.
I’ve got rewrite analyzer installed, but I don’t think that’s the problem as this URL appears to work correctly: http://www.seriouslyfish.com/species/search/betta
.
Any idea what could be causing this? I’m not 100% sure that the problem lies with the changing of the URL, as none of the code needed to change.
.htaccess
RewriteEngine On
RewriteCond %{QUERY_STRING} genus=([a-zA-Z0-9-]+)&species=([a-zA-Z0-9-]+)
RewriteRule ^profile.php$ /species/%1-%2? [L,R=301]
RewriteCond %{QUERY_STRING} id=([0-9]*)
RewriteRule ^profile.php$ calc.php?id=%1 [L,R=301]
RewriteRule ^kb.php$ /knowledge-base/ [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
wp-config.php (or, a couple of the lines in it – nothing else relating to URLs exists in the file)
define('WP_SITEURL', 'http://www.seriouslyfish.com');
define('WP_HOME', 'http://www.seriouslyfish.com');
the form actions
PROFILESEARCH
<h1 class="profilesearch">PROFILE<span class="white">SEARCH</span></h1>
<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" />
<label style="width: 180px;">SEARCH FISH SPECIES PROFILES</label>
</form>
QUESTIONSSEARCH
<h1 class="profilesearch">QUESTION<span class="white">SEARCH</span></h1>
<form id="profilesearch" action="<?php echo qa_get_url('archive'); ?>" method="post">
<input type="hidden" name="type" value="profile" />
<input type="text" size="50" class="default-value" value="<?php the_search_query(); ?>" name="s" />
<input type="submit" value="GO" class="profilesearch_submit" />
</form>
GLOSSARYSEARCH
<div class="glossary" href="#">
GLOSSARY <strong class="dkblue">▼</strong>
<span>
<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>
<div class="glossaryletters">
<a href="http://wordpress.stackexchange.com/glossary/a/">A</a>
...
<a href="http://wordpress.stackexchange.com/glossary/z/">Z</a>
<div class="clear"></div>
</div>
</span>
</div>
custom_rewrite function
/* --- rewrite rules for searches...*/
function custom_rewrite( $wp_rewrite ) {
$species = array(
'(species|glossary)/search/(.+?)(/page/([0-9]+))?/?$' => 'index.php?post_type=".$wp_rewrite->preg_index(1)."&s=".$wp_rewrite->preg_index(2)."&paged='.$wp_rewrite->preg_index(4)
);
$wp_rewrite->rules = $species + $wp_rewrite->rules;
}
// refresh/flush permalinks in the dashboard if this is changed in any way
add_filter( 'generate_rewrite_rules', 'custom_rewrite' );
Thanks in advance,