0

what I need is this: add a term from a custom post to the post's title. Like this: Custom Post title - term

Right now I have:

$terms_of_post = strip_tags (get_the_term_list( $post->ID, 'my-custom-term', '','', '', '' ));

elseif ( is_single() ) { single_post_title(); {echo ' ('; echo $terms_of_post;  echo ')';} ; }       

I don't know why it doesn't work, but it seems it should.

I have found Copy a Taxonomy Term into the Post Title for a certain Custom Post Type, which could be 90% of the answer, but instead of replacing the post title with the taxonomy title, I need to add it to the title.

Thanks a lot!

1

You can try this (based on your unfinished PHP code)

if ( is_single() ) { 
    $terms_of_post = get_the_term_list( get_the_ID() , 'my-custom-term', '',', ', '', '' );
    $terms_of_post = strip_tags ( $terms_of_post );
    single_post_title(); 
    if( $terms_of_post ){
        echo ' (' . $terms_of_post . ')';
    }
}   

to get this format:

Title (term1, term2, term3)
2
  • Thanks a lot! My connection was down and I could not test this. But I can confirm it works. – JenRe Jun 11 '13 at 17:28
  • ok, great to hear that, cheers. – birgire Jun 11 '13 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.