IMPORTANT UPDATE: I\'ve realised that my problems could also lie with the WordPress 3.3 update.
不久前我posted a solution to my own question 关于搜索自定义帖子类型。
当时,我正在使用URLhttp://www.seriouslyfish.com/dev/
我重新开发了网站。
现在我“上线”了,把一切都搬到了http://www.seriouslyfish.com
.
出于某种原因,这似乎破坏了我的自定义帖子类型搜索。如果您尝试从“PROFILESEARCH“或”QUESTIONSEARCH“框,您将看到它正在重定向到/search/
而不是/questions/search
或/species/search
.
我已经安装了重写分析器,但我认为这不是问题所在,因为此URL似乎工作正常:http://www.seriouslyfish.com/species/search/betta
.
你知道这是什么原因吗?我不能百分之百确定问题在于URL的更改,因为没有任何代码需要更改。
<小时>
.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 (或者,其中有几行-文件中没有其他与URL相关的内容)
define(\'WP_SITEURL\', \'http://www.seriouslyfish.com\');
define(\'WP_HOME\', \'http://www.seriouslyfish.com\');
<小时>
the form actions
档案搜索<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>
问题搜索
<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>
词汇搜索
<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="/glossary/a/">A</a>
...
<a href="/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\' );
提前谢谢你,