我有一个WordPress网站。我创建了一个自定义模板页面,如下所示:
/archive-template.php?posttype=publications&taxo=countries&slug=kenya
如何使用permalink获得这些链接。htaccess?插件?因此,上面的链接如下所示:/archives/publications/countries/kenya
我有一个WordPress网站。我创建了一个自定义模板页面,如下所示:
/archive-template.php?posttype=publications&taxo=countries&slug=kenya
如何使用permalink获得这些链接。htaccess?插件?因此,上面的链接如下所示:/archives/publications/countries/kenya
添加以下代码
在主hooks文件中(可能在functions.php)
add_action(\'init\', \'my_custom_rewrite_rules\');
然后添加此函数function my_custom_rewrite_rules() {
// The rule
// Input: archives/publications/countries/kenya
// Output: archive-template.php?posttype=publications&taxo=countries&slug=kenya
add_rewrite_rule(\'archives/publications/countries/([^/]+)/\', \'archive-template.php?posttype=publications&taxo=countries&slug=$matches[1]\', \'top\');
// Flush the rules (to activate them)
flush_rewrite_rules();
}
要了解有关regex和重写规则的更多信息,这些链接可能会有所帮助NOTE 很抱歉,我没有为您编写规则,我确实遇到了一些问题,没有时间编写规则并进行测试,但是,我希望我提供的资源能够帮助您。祝你好运
NOTE 2 已更新规则。它未经测试。但这应该给你一个好的开始。
我需要获取所有帖子ID、帖子标题和相应的meta\\u值,该值是自定义帖子类型的“特色”。我想我需要加入,但我不知道他们是怎么工作的。。谁能帮我一下吗?