wp_count_terms()  CPT-onomies Documentation  

wp_get_object_terms()

Description

Retrieves the terms associated with the given object(s), in the supplied CPT-onomies.

As of 1.1, you can add the parameter ‘exclude’ to your $args array, specifying term ids to exclude from your results. ‘exclude’ can be defined as an array, comma- or space-delimited string and will only work if the ‘fields’ parameter is set to ‘ids’, ‘all’, or ‘all_with_object_id’.

Usage

wp_get_object_terms( string|array $object_ids, string|array $cpt_onomies, string|array $args );

Parameters

$object_ids (string|array) (required)
Default: none
The ID's of objects to retrieve terms from.

$cpt_onomies (string|array) (required)
Default: none
Name of the CPT-onomy to retrieve terms from. Can include multiple CPT-onomies.

$args (string|array) (optional)
Default: none
Arguments to customize what data is returned.
For information on how to customize the $args parameter, refer to the WordPress codex.

Return Values

(array|WP_error) The requested term data on success, an empty array if no terms are found, and a WP_error object if an invalid $cpt_onomy is entered.

Term object fields:

  • term_id
  • name
  • slug
  • term_group
  • term_taxonomy_id
  • taxonomy
  • description
  • parent
  • count

Examples

Returns a list of all 'actors' CPT-onomy terms (which are applied to $post) with a link to each term's archive page:
Note: You must use the $cpt_onomy class to retrieve the term's archive link ( get_term_link() ).

<?php

global $cpt_onomy;
$terms = wp_get_object_terms( $post->ID, 'actors' );
if ( $terms && !is_wp_error( $terms ) ) {
   echo '<ul>';
   foreach ( $terms as $term ) {
      echo '<li><a href="' . $cpt_onomy->get_term_link( $term, $term->taxonomy ) . '">' . $term->name . '</a></li>';
   }
   echo '</ul>';
}

?>

, , , , ,

WordPress Codex

For more information, refer to the WordPress codex.

wp_count_terms()  CPT-onomies Documentation  
  • Jean-Paul

    i’m trying to get the picture but nothing when i try with  $term->thumbnail or $term->pictures, how i can display thumbnail from my custom post type ?

  • Jean-Paul

    I found something : put get_the_post_thumbnail($term->term_id, ‘thumbnail’);

    • rachelcarden

      Awesome! Glad you found the answer.