Show taxonomy term without hyperlink (disable link of taxonomy term)

Hi!
Is there anyway to show taxonomy term without hyperlink (disable link of taxonomy term)? I tried disabling Public Queryable under CPT UI however it will redirect to homepage which is redundant.
Thanks in advance!

1 Like

Hi Thomas,
Welcome to the forum and thanks for reaching out!

Unfortunately, it isn’t possible to remove the link from the taxonomy term using a dynamic data field, but you can simply output the taxonomy term using PHP:

<?php 
  $terms = get_the_terms( get_the_ID(), 'your_taxonomy_name' ); 
  foreach($terms as $term) {
    echo $term->name;
  }
?>

Best regards,
timmse

2 Likes

Getting a taxonomy term as id or slug inside a post should be on the to-do list then please, oxygen has a function in the dynamic data for that. We need it for conditional styling of elements based on the taxonomy. For example i use custom attributes to set a background color. Now i need to add that variable with PHP and JS (example below)

<?php
$terms = get_the_terms( get_the_ID(), 'opvangsoort' );
if ( !empty( $terms ) ){
    // get the first term
    $term = array_shift( $terms );
}
?>
<script>
document.getElementById("brx-content").setAttribute("vacature_header_background_color", "<?php 
echo $term->slug;
?>");  
</script>

And/Or target the attribute selectors with a wildcard of the URL i get when using dynamic data:

[sidebar_background_color*='kinderdagverblijf'] {
	background-color: var(--bricks-color-sxiddf);
}
[sidebar_background_color*='buitenschoolse-opvang'] {
	background-color: var(--bricks-color-sxiddf);
}
[sidebar_background_color*='peuteropvang'] {
	background-color: var(--bricks-color-ayjprw);
}
[sidebar_background_color*='staf'] {
	background-color: var(--bricks-color-bhrphe);
}
[sidebar_background_color*='werken-leren'] {
	background-color: var(--bricks-color-tqeiso);
  color: var(--bricks-color-dxvxao);
}

Ofcoursei prefer the ID as the slug could change

1 Like

Inserted this as PHP snippet (WP Code) and got error:
Invalid argument supplied for foreach()

Worked great for me. Just pop in a little code block and voila!