I’ve a customized submit sort which makes use of customized classes (taxonomy) – known as project-type
with 2 ranges of heirachy that are tagged to completely different posts.
When viewing the customized submit web page I need a manner to have the ability to render the customized classes it’s tagged with – I’ve this working utilizing get_the_term_list
as per code beneath:
<?php
$the_terms = get_the_term_list( get_the_id(), 'project-type', __( "" ) . "<li>", "<span class="sf-sub-indicator"><i class="fa fa-angle-right icon-in-menu" aria-hidden='true'></i></span></li><li>", "<span class="sf-sub-indicator"><i class="fa fa-angle-right icon-in-menu" aria-hidden='true'></i></span></li>" );
?>
<ul>
<li><a href="/initiatives/">PROJECTS</a><span class="sf-sub-indicator"><i class="fa fa-angle-right icon-in-menu" aria-hidden='true'></i></span></li>
<?php echo $the_terms; ?>
</ul>
This works nicely, BUT… what I would like to have the ability to do is add an identifier – class title or ID to the <li>
based mostly on its heirachy inside the customized classes I’m utilizing.
So for the highest stage classes the submit is tagged with, id like so as to add “level1” class to the LI and for the 2nd stage classes the submit is tagged with we add “level2” class to the LI.
So for instance: Customized classes:
Cat Guardian A
Cat Youngster AA
Cat Youngster AB
Cat Guardian B
Cat Youngster BA
Cat Youngster BB
And if the customized submit was tagged with Cat Guardian A
and Cat Youngster AB
– then the present output of the phrases fetched could be:
<ul>
<li><a href="/initiatives/">PROJECTS</a><span class="sf-sub-indicator"><i class="fa fa-angle-right icon-in-menu" aria-hidden='true'></i></span></li>
<li><a href="/slug/">Cat Guardian A</a><span class="sf-sub-indicator"><i class="fa fa-angle-right icon-in-menu" aria-hidden='true'></i></span></li>
<li><a href="/slug/">Cat Youngster AB</a><span class="sf-sub-indicator"><i class="fa fa-angle-right icon-in-menu" aria-hidden='true'></i></span></li>
</ul>
My desired end result with the addition of those lessons could be:
<ul>
<li><a href="/initiatives/">PROJECTS</a><span class="sf-sub-indicator"><i class="fa fa-angle-right icon-in-menu" aria-hidden='true'></i></span></li>
<li class="level1"><a href="/slug/">Cat Guardian A</a><span class="sf-sub-indicator"><i class="fa fa-angle-right icon-in-menu" aria-hidden='true'></i></span></li>
<li class="level2"><a href="/slug/">Cat Youngster AB</a><span class="sf-sub-indicator"><i class="fa fa-angle-right icon-in-menu" aria-hidden='true'></i></span></li>
</ul>
How can I obtain this?
I’d additionally just like the dad or mum > youngster, dad or mum > youngster format within the outputted UL as that is being rendered as a breadcrumb exhibiting which customized taxonomies the customized submit is tagged with on the web page.
If there’s a higher technique to obtain this I’m open to altering how this breadcrumb is created.