Aleš Sýkora / November 28, 2023 / 5 comments

Display post tags without links in Oxygen builder

Post summary: If you add the post_tag by dynamic data option in text block – for example in post or in repeater – then it displays the tag as a link to the tag’s archive. You can do the same to display categories without links in Oxygen builder. But what if you don’t want the tag archive…

If you add the post_tag by dynamic data option in text block – for example in post or in repeater – then it displays the tag as a link to the tag’s archive.

You can do the same to display categories without links in Oxygen builder.

But what if you don’t want the tag archive link? Add this function to the Oxygen Code block:

<?php
  $tags = get_the_tags();
  if ($tags) {
    foreach($tags as $tag) {
      echo $tag->name . ' '; 
    }
  }
?>

If you want to change the separator, change this:

echo $tag->name . ' '; 

To whatever you want… for example:

echo $tag->name . '||||||||||||my fancy separator||||||||||'; 

If you need to use this code on more than one page, I suggest you create it as a function and put to the code snippets or advanced scripts:

<?php function great_tit_tagnames() {
  $tags = get_the_tags();
  if ($tags) {
    foreach($tags as $tag) {
      echo $tag->name . ' '; 
    }
  }
}
?>

And then just add the Text block > Dynamic Data > PHP function return value

That will generate this Oxygen shortcode, which you can use sitewide with function in one place.

[oxygen data='phpfunction' function='great_tit_tagnames']

Another solution is using code block as a re-usable block.

Fuel my passion for writing with a beer🍺

Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻

5 comments

Share Your Thoughts