Tell us what you are trying to do?
We'd like to be able to render the Name of Taxonomy labels on search views and other areas, by referencing the slug of that taxonomy. It looks like it's possible from previous tickets, but the solution urls aren't accessible.
<label>[show the name of taxonomy with slug:filter1]</label>
[wpv-post-taxonomy type="filter1"]
Would it be possible to get an update on this, I've tried the following solutions which look exactly what we're trying to achieve but it's not rendering the taxonomy name.
To get the title/label of a Taxonomy using its slug, you can use "get_taxonomies" function ( ref: https://codex.wordpress.org/Function_Reference/get_taxonomies ), to first get all the taxonomies and then only show the title/label, if the provided slug, matches.
Example:
add_shortcode('taxonomy-label-by-slug', 'taxonomy_label_by_slug_func');
function taxonomy_label_by_slug_func($atts, $content){
$atts = shortcode_atts( array(
'slug' => '',
), $atts );
$args = array(
'public' => true,
'_builtin' => true
);
$output = 'objects';
$operator = 'or';
// get all taxonomies
$taxonomies = get_taxonomies( $args, $output, $operator );
foreach ($taxonomies as $taxonomy) {
// if the provided slug matches, save and return the Title/Label
if ($taxonomy->name == $atts['slug']) {
$label = $taxonomy->label;
}
}
return $label;
}
The shortcode can be used with a slug like this:
[taxonomy-label-by-slug slug="taxonomy-slug"]
I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors: https://toolset.com/contractors/