Thursday, August 25, 2022
The Great Tit
Updated: 20. 9. 2022, Added: 25. 8. 2022

Display post categories without links in Oxygen builder

If you want display post categories without the links in repeater or in post page without link to the category archive, you can use the code below.

<?php
  foreach (get_categories() as $category){
    echo $category->name . ' ';
  } 
?>

If you want to change the separator, change this:

echo $category->name . ' '; 

To whatever you want... for example:

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

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

<?php function great_tit_catnames() {
  foreach (get_categories() as $category){
    echo $category->name . ' ';
  } 
}
?>

And then just add the Text block > Dynamic Data > PHP function return value and to the first input add the "great_tit_catnames". That will generate this Oxygen shortcode, which you can use sitewide with function in one place:

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

Another solution would be using code block as a re-usable block.

Did I help you? Support me on Patreon!
Beep this article to your friends!

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.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram