custom post types - How to get rewrited name of cusom taxonomy?

I have registered custom post taxonomy with rewrited name:register_taxonomy('behold_gallery-albums-subject',

I have registered custom post taxonomy with rewrited name:

register_taxonomy('behold_gallery-albums-subject', 'behold_gallery',array(
    'hierarchical'              => true,
    'labels'                    => $labels,
    'show_ui'                   => true,
    'show_admin_column'         => true,
    'rewrite'                   => array( 'slug' => 'kategorie-galerii', 'with_front' => true ),
    'update_count_callback'     => '_update_post_term_count',
    'query_var'                 => true,
));

so name of my custom taxonomy is 'behold_gallery-albums-subject' but is rewrited to 'kategorie-galerii'.

If I want to get name of this taxonomy, I can use this

$postsTaxonomy = get_sub_field('archive__post-choose-taxonomy'); // ACF
$postsTerm = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
$postsTerm_id = $postsTerm->term_id;
$PostsTaxName = get_taxonomy($postsTaxonomy)->labels->name;

but how can I get this rewrited name, not the 'original'?

Thanks!

I have registered custom post taxonomy with rewrited name:

register_taxonomy('behold_gallery-albums-subject', 'behold_gallery',array(
    'hierarchical'              => true,
    'labels'                    => $labels,
    'show_ui'                   => true,
    'show_admin_column'         => true,
    'rewrite'                   => array( 'slug' => 'kategorie-galerii', 'with_front' => true ),
    'update_count_callback'     => '_update_post_term_count',
    'query_var'                 => true,
));

so name of my custom taxonomy is 'behold_gallery-albums-subject' but is rewrited to 'kategorie-galerii'.

If I want to get name of this taxonomy, I can use this

$postsTaxonomy = get_sub_field('archive__post-choose-taxonomy'); // ACF
$postsTerm = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
$postsTerm_id = $postsTerm->term_id;
$PostsTaxName = get_taxonomy($postsTaxonomy)->labels->name;

but how can I get this rewrited name, not the 'original'?

Thanks!

Share Improve this question asked Jun 30, 2020 at 15:33 D_PD_P 1531 gold badge3 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Do you mean just get the rewritten slug? From the docs it looks like you should be able to do:

$rewrite_name = get_taxonomy($postsTaxonomy)->rewrite['slug']

Or do you mean something else?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742305485a4418852.html

相关推荐

  • custom post types - How to get rewrited name of cusom taxonomy?

    I have registered custom post taxonomy with rewrited name:register_taxonomy('behold_gallery-albums-subject',

    20小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信