Wordpress: disable links for get_the_category_list function?

php, wordpress

Solution

If you just want a text-string returned and use the native `get_the_categories()` function, you could simply wrap it in PHP's `strip_tags()` function to remove all HTML that is returned:

echo strip_tags( get_the_category_list(__( ', ', 'gridster' ));

Problem

Hey my theme uses this function to display the categories a post has, but it also creates links which I would like to get rid of. I prefer php rather than a javascript solution. Here is the code: ``` <p class="postmeta"> <?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?> <?php /* translators: used between list items, there is a space after the comma */ $categories_list = get_the_category_list( __( ', ', 'gridster' ) ); if ( $categories_list && gridster_categorized_blog() ) : ?> <?php /*printf( __( '%1$s', 'gridster' ), $categories_list );*/ echo $categories_list; ?> <?php endif; // End if categories ?> <?php endif; // End if 'post' == get_post_type() ?> </p> ``` Link to the codex reference How can I void those links? or get rid of links all together from DOM (but this might create more work as the actual text is between the `<a>` tags HTML ``` <p class="postmeta"> <a target="_blank" href="http://whatever.com/category/default/" title="View all posts in Default" rel="category tag">Default</a> </p> ``` Thanks!!

Original source