I’ve searched far and wide to try and find an answer to my question. I’m hoping I can get help here. Here goes…

I’m currently retrieving the terms of my custom taxonomy using:

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

What I’m trying to do is retrieve these same post-specific custom taxonomy terms in a list without them being output as links. I’ve tried all of the following “solutions,” but none of them work. Any help would be appreciated.

Returns the post-specific terms in one long string that can’t be put in a list:

$terms_as_text = get_the_term_list( $post->ID, 'skills', '<ul><li>', '</li><li>', '</li></ul>' ) ;
echo strip_tags($terms_as_text);

Returns a list of all the terms used across all the custom post types:

<ul>
<?php $args = array( 'taxonomy' => 'skills', 'orderby' => 'ID', 'order' => 'ASC' );
$categories = get_categories( $args );
foreach($categories as $category) { echo '<li> '. $category->name . '</li>'; } 
                ?>
</ul>

Returns nothing:

<?php $args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all');
wp_get_object_terms( $post->ID, $skills, $args );
?>

I’ve even tried get_the_terms, get_terms, and get_categories to no avail.

8 Answers
8

Can try this:

$terms = get_the_terms ($post->id, 'skills');
if ( !is_wp_error($terms)) : ?>

<?php 
    $skills_links = wp_list_pluck($terms, 'name'); 

    $skills_yo = implode(", ", $skills_links);
    ?>

    <span><?php echo $skills_yo; ?></span>

Leave a Reply

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