Aleš Sýkora wrote

WordPress term list without links

1. 7. 2021 in ,

If you use the_terms for list of posts taxonomy terms, then you get the list with automatically added links. Sometimes you do not need the links. Then you can use the strip_tags.

Get term list with links

<?php the_terms( 0, 'tax-slug'); ?>

Get term list without links

<?php echo strip_tags(get_the_term_list( $post->ID, 'tax-slug', ' ',', ')); ?>

Get the terms custom output

global $post;
$terms = get_the_terms( $post->ID, 'tax-slug');
if ($terms > 0) {
    foreach($terms as $term) {
        echo '<a class="c-text-s c-link-accent" href="' . get_term_link($term) .'">' . $term->name . '</a>';

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More from category
Aleš Sýkora wrote
Child posts menu for custom post type parent item
1. 2. 2021 in
This code will help you display menu of childs on current post. For example: Product 1 = parent has those child pages: – Product usage– How to– Disclaimer– Calculator When you put this child items menu in your template, it will show all childs of product 1 on all child pages and also on product […]
Read More
Aleš Sýkora wrote
Disable WordPress admin bar for all except admins
17. 6. 2021 in
If you have your custom administration for users made with Toolset, you will propably need to hide the admin bar for your users except administrators. So if you have this question: “When you are logged in, the black wordpress top bar is showing up – is it possible to hide this bar for all users […]
Read More
Aleš Sýkora wrote
Get homepage link as a logo link in Oxygen Builder
Wrap your website’s logo in link wrapper and use this PHP function inside, to create the Home link.
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram