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 badges1 Answer
Reset to default 0Do 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?