Hi, please keep in mind this is a public forum. For your security, I have removed the login information from this post. If you would like to share private information in the future, a supporter can open private reply fields so the information is not shared publicly.
I need the the top one one to pull through the main category name its just pulls through the parent - Arts and Craft (see attached "Category layout")...the shortcode i am using on the toolset is [wpv-archive-title] I just need the shortcode that shows the main category please.
If you want to display the title of the current archive term (i.e. on /categories/arts-and-crafts/frame-maker/ you want to display "Frame Maker"), you can use the shortcode wpv-taxonomy-title: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-taxonomy-title
If you want to display the title of the current archive term's parent, that is a bit different. Unfortunately there is no Toolset shortcode available to get the title of the current archive term's parent term. Instead, I have a custom shortcode you can use to get that parent term name. This code can be added in your child theme's functions.php file, or to a new custom code snippet in Toolset > Settings > Custom Code:
function get_term_parent_func($atts) {
$a = shortcode_atts( array(
'taxonomy' => '',
'return' => 'title'
), $atts );
$taxonomy = $a['taxonomy'];
$parent_id = 0;
if( is_tax( $taxonomy ) ) {
$taxObj = get_queried_object();
$tax = isset($taxObj->taxonomy) ? $taxObj->taxonomy : 0;
$term = isset($taxObj->term_id) ? $taxObj->term_id : 0;
$parent_slug = get_term_parents_list( $term, $tax, array('format'=>'slug', 'link'=>FALSE, 'inclusive'=>FALSE, 'separator'=>''));
if( $a['return'] == 'id' ) {
$parent = get_term_by( 'slug', $parent_slug, $tax );
$parent_id = isset($parent->term_id) ? $parent->term_id : $taxObj->term_id;
return $parent_id;
}
if( $a['return'] == 'slug' ) {
return $parent_slug;
}
if( $a['return'] == 'title' ) {
$parent = get_term_by( 'slug', $parent_slug, $tax );
$parent_title = isset($parent->name) ? $parent->name : $taxObj->name;
return $parent_title;
}
}
return $parent_id;
}
If no parent term exists, the code will display the current archive term title. If you would like something else displayed when no parent term exists in the current archive, please explain.
After you add the code above, you can display the parent term title using the custom shortcode in your archive design like this:
[get_term_parent taxonomy='your-taxonomy-slug' return='title'][/get_term_parent]
Replace your-taxonomy-slug with the slug of the categories taxonomy. You can find the taxonomy slug in Toolset > Taxonomies when you edit the categories taxonomy.
Let me know if I've misunderstood what you want to accomplish.