Hi, I have a few custom posts and would like to display the custom categories for those posts in the results. I found this code but doesnt seem to be working for me (see below)
The name of the category is ‘venues-category’.
Also in the Advanced Title Field what would I need to type to show the category? {venues-category} ?
add_filter( ‘asp_pagepost_results’, ‘asp_add_category_titles’, 1, 1 );
function asp_add_category_titles( $pageposts ) {
foreach ($pageposts as $k=>$v) {
// Get the post categories
$post_categories = wp_get_post_categories( $pageposts[$k]->id );
$cats = “”;
// Concatenate category names to the $cats variable
foreach($post_categories as $c){
$cat = get_category( $c );
$cats = ” “.$cat->name;
}
// Modify the post title
$pageposts[$k]->title .= ” “.$cats;
}
return $pageposts;
}