Reply To: Category Name Filter Not Working

#6619
ar
ar
Participant

Firstly, thank you so much for the speedy reply!

I tried the code above using the taxonomy single name, the plural name and the slug without success.

code is below:


add_filter( 'asp_pagepost_results', 'asp_add_term_titles', 1, 1 );
 
function asp_add_term_titles( $pageposts ) {
  foreach ($pageposts as $k=>$v) {
 
    // Edit this to the taxonomy you are using
    $taxonomy = "Design";
 
    // Get the taxonomy terms
    $post_terms = wp_get_post_terms( $pageposts[$k]->id, $taxonomy );
    $terms = "";
 
    // Concatenate category names to the $cats variable
    foreach($post_terms as $c){
        $term = get_term( $c, $taxonomy );
        $terms = " ".$term->name;
    }                
 
    // Modify the post title
    $pageposts[$k]->title  .= " ".$terms;
  }
 
  return $pageposts;
}

any thoughts on what else I might try?

Many thanks for your help,
Anne