php - Comma separate custom taxonomies (no links) -


here's simple little question can't seem figure out. have 1 custom taxonomy has multiple options. want show taxonomies without links. use code:

<li>     <?php         $terms_as_text = get_the_term_list($post->id, 'opties');          if (!empty($terms_as_text)) echo '', strip_tags($terms_as_text) , '';     ?> </li>  

this display's selected custom taxonomies of opties. because taxonomy has multiple options comma separate them. won't let me.

normally use:

<?php echo get_the_term_list( $post->id, 'opties', '<ul><li>', '</li><li>', '</li></ul>' ); ?>

  • the first part = before.
  • the middle part = separate.
  • the last part = after.

but makes links of custom taxonomy terms, , don't want happen.

but because of strip_tags($terms_as_text) can't comma separate them.

how can them separate comma?

you can try following:

global $post; $opties = wp_get_post_terms($post->id, 'opties', array("fields" => "names")); if (count($opties) > 0) {     echo implode(', ', $opties); } 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -