我安装了edd插件并添加了产品。当我单击单个页面的产品或单击插件生成的链接http://site_url/downloads/category/recent-issues/
的任何edd类别时。现在我想更改帖子类型的 slug。
喜欢
http://site_url/downloads/category/recent-issues/
自
http://site_url/issues/category/recent-issues/
我从谷歌搜索并找到了这个代码。
function add_custom_rewrite_rule() {
$current_rules = get_option('rewrite_rules');
if( ($current_rules) ) {
foreach($current_rules as $key => $val) {
if(strpos($key, 'download') !== false) {
add_rewrite_rule(str_ireplace('download', 'issues', $key), $val, 'top');
} // end if
} // end foreach
} // end if/else
// ...and we flush the rules
flush_rewrite_rules();
} // end add_custom_rewrite_rule
add_action('init', 'add_custom_rewrite_rule');
但是这段代码不起作用。"下载"是EDD产品的帖子类型。
那么我该如何更改 edd 帖子类型的 slug。
只需
一行代码即可实现您想要的。
define('EDD_SLUG', 'issues');
删除上面的代码并将此代码粘贴到函数.php中。
有关参考,请阅读本文。