使用钩子更改分类法”分层”设置

我正在使用来自存储库的免费Real Estate WordPress插件, 但已支付了支持费用。

无论如何, 插件的”城市”分类不是分层的。我需要使其成为HIERARCHICAL, 以便可以在其下创建带有分层城市的县。如你所知, 出于已知原因, 无法修改插件的文件(更新覆盖)。

我正在寻找这样的事情部署在functions.php中:

function change_post_object_label( $taxonomy_args ) {
    $taxonomy_args->hierarchical = true;
}
add_action( 'taxonomy_hook', 'change_taxonomy_args' );

是否存在?如何在不更改php文件的情况下将给定分类法的层次结构设置为” true”?


#1


如果你使用的是WordPress 4.4或更高版本, 则可以使用register_taxonomy_args过滤器。

将此添加到你的functions.php中, 不要忘记使用实际的分类标准。

function filter_register_taxonomy_args( $args, $taxonomy ) {

    if ( $taxonomy === 'taxonomy_slug_here' ) {

        $args['hierarchical'] = true;
    }
    return $args;
}
add_filter( 'register_taxonomy_args', 'filter_register_taxonomy_args', 10, 2 );

来源:

https://www.srcmini02.com/62904.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_42078.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?