Reply To: Category Name Filter Not Working

Ernest Marcinko
Ernest Marcinko


I think the problem here might be that you are using a custom taxonomy.

I suppose you are talking about this example:

This only works with post categories, because for other taxonomy terms a different wordpress function is used. I’ve made a quick modification, that should get the terms of the specified taxonomy:

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 = "mytaxonomy";
    // 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;

Don’t forget to change the $taxonomy variable to the taxonomy you are using with the custom post type.

Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)