Support » Plugin: CPT-onomies: Using Custom Post Types as Taxonomies » [Plugin: CPT-onomies: Using Custom Post Types as Taxonomies] Term excerpt/description?

  • Resolved ncfrank


    Wonderful plugin. It’s super awesome!

    I’m sure I’m missing something simple here, but from looking around I haven’t seen an answer. Apologies if I missed it in the documentation.

    Ultimately I’m looking to have:
    1. An archives page that shows all the different kinds of agencies(that also shows their excerpt/description) (this piece already works with excerpts.)
    2. When you click on an agency entry and goto a specific agency CPT-onomy term
    I’d like to show that excerpt/description at the top of the page above the list of posts (defined as a different CPT-onomy: “Projects”)they are related to to provide context to the reader.

    Some things I’m trying:

    In the tags and categories taxonomies there’s a description field, and it’s even seen if you var_dump;

    $agencies = wp_get_object_terms( $post->ID, "agencies" );
    if ( $agencies && !is_wp_error( $agencies ) ) {
       foreach ( $agencies as $agency ) {
          $line = $agency->name;
    	   var_dump($cpt_onomy->get_term($agency, "agencies"));
    	   var_dump(term_description( $agency, "agencies" ));
    	  echo $line;

    They all come back with a description field that is empty:

      string(0) ""

    It makes sense as I don’t see a description field when I create a new agency entry, but there is a field returning, perhaps there’s a way to add a field to enter that data on the term entry page(add new agency)?
    Perhaps this is apart of:
    not working with wordpress “right now”

    I noticed in the cpt-onomy.php (function convert_object_to_cpt_onomy_term) has:

    $term = array(
    					'term_id' => $term->ID,
    					'name' => apply_filters( 'the_title', $term->post_title, $term->ID ),
    					'slug' => $term->post_name,
    					'term_group' => $term->post_parent,
    					'term_taxonomy_id' => 0,
    					'taxonomy' => $term->post_type,
    					'description' => '',
    					'parent' => $term->post_parent

    which seems to show that the description is being set to empty.

    I have enabled custom fields, and tried to enter a description there, I’m sure there’s more I’d need to do to access that info (any thoughts here?)

    I’ve set up my CPT-onomy to have excerpts, and have populated them, perhaps I could use those?

    Thanks for any of your time for your thoughts/links to more reading.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Rachel Cherry


    Hi! First off, I’m glad you like the plugin! It is a labor of love!

    Second, at this time term descriptions don’t work with CPT-onomies because CPT-onomy information is stored differently than regular taxonomy information so there’s no set place to store a defined “cpt-onomy term description” at this point in time.

    That being said, the custom post does have its “post_content” and “excerpt” fields, as well as custom fields to fulfill any “description” needs.

    If you’re fine with using the “excerpt”, you could add the following code inside your foreach loop:

    echo apply_filters( 'the_excerpt', get_post( $agency->term_id )->post_excerpt );

    Or you could setup a custom field for your description and retrieve the info with the following code inside your loop. For this example, the custom field key will be ‘description’:

    get_post_meta( $agency->term_id, 'description', true );

    Hope this helps!

    hi, i have the same problem.
    i’ve tried this code:

    $terms = get_the_terms( $post->ID, 'negozi' );
    if ( $terms && ! is_wp_error( $terms ) ) {
       $negozi = array();
       foreach ( $terms as $term ) {
        $negozi[] = $term->name;
    echo apply_filters( 'the_excerpt', get_post( $negozi->term_id )->post_excerpt );
       $negozi = join( ", ", $negozi );

    but seems doens’t print the excerpt

    thanks in advance

    solved with this code

    $negozi = wp_get_object_terms( $post->ID, ‘negozi’ );
    $negozi = get_the_terms( $post->ID, ‘negozi’ );
    foreach ( $negozi as $negozi ) {
    echo apply_filters( ‘the_excerpt’, get_post( $negozi->term_id )->post_excerpt );


    Plugin Author Rachel Cherry


    Awesome! Glad you solved it!

    thanks Rachel.
    since you’re so kind, i would like to ask you if there is a better way to have the number of CPT in taxonomy than this

    $negozi = wp_get_object_terms( $post->ID, ‘negozi’ );
    $negozi = get_the_terms( $post->ID, ‘negozi’ );
    $nome_negozio = apply_filters( ‘the_slug’, get_post( $negozi->term_id )->post_name );
    $query = new WP_Query( array( ‘negozi’ => $nome_negozio ) );
    $num_coupon = $query->found_posts;
    echo $num_coupon;

    Plugin Author Rachel Cherry


    Both wp_get_object_terms() and get_the_terms() should include a ‘count’ in the term object, e.g. $negozi->count.

    Give that a shot.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: CPT-onomies: Using Custom Post Types as Taxonomies] Term excerpt/description?’ is closed to new replies.