我创建了三个分类法,分别命名为“城市”、“公司”和“职业”。该分类法的链接结构如下:
/city/london
/company/cocacola
/profession/sales
我想在公司和职业分类法的末尾使用城市分类法。这样,我想根据城市筛选公司和职业。见下表:/company/cocacola/london
/profession/sales/london
这样做有可能吗?如果是,我该怎么做?有其他选择吗?我创建了三个分类法,分别命名为“城市”、“公司”和“职业”。该分类法的链接结构如下:
/city/london
/company/cocacola
/profession/sales
我想在公司和职业分类法的末尾使用城市分类法。这样,我想根据城市筛选公司和职业。见下表:/company/cocacola/london
/profession/sales/london
这样做有可能吗?如果是,我该怎么做?有其他选择吗?通过改变add_permstruct
或筛选rewrite_rules
. 但是,您的链接生成策略是什么city
? 如何实现第二种分类法?
我会把它作为重写规则来实现,比如
add_filter( \'rewrite_rules_array\', function( $rules ) {
global $wp_rewrite;
$new_rules = array(
\'(company|profession)/([^/]+)/([^/]+)/?$\' => \'index.php?$matches[1]=$matches[2]&city=$matches[3]\'
);
$rules = array_merge($new_rules, $rules);
return $rules;
});
然而,这并不是最优的,您需要生成一组受支持的规则(分页提要)。但你仍然需要为他们生成链接,这取决于你!干杯
我已将wordpress项目导出并导入live server。现在的问题是,我将permalink结构作为“localhost”格式。当我单击网站中的任何链接时,它会将我重定向到localhost。我怎样才能改变这一点?我的htaccess文件如下所示<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /myproject/ RewriteRule ^index\\.php$ - [L] RewriteCo