Gday Enfold users
I would like to replace the blog title with the CATEGORY of each blog post.
I have tried unsuccessfully with:
add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
function fix_single_post_title($args,$id)
{
if ( $args['title'] == 'Blog - Latest News' )
{
$args['title'] = get_the_category($category[0]);
$args['link'] = get_permalink($id);
$args['heading'] = 'h1';
}
return $args;
}
It returns the term ‘Array’ when there are multiple categories chosen. I am hoping I can return the first Category.
Thanks for any help you can provide.
cheers
Darryl
Hey itchybrain!
Try this out.
add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
function fix_single_post_title($args,$id)
{
$category = get_the_category($id);
if ( $args['title'] == 'Blog - Latest News' )
{
$args['title'] = $category[0]->name;
$args['link'] = get_permalink($id);
$args['heading'] = 'h1';
}
return $args;
}
Regards,
Elliott
You beauty Elliot, thanks so much for this! It will make my client very happy…much appreciated.
I have also been able to follow your logic and reproduce this for post tags as well.
Thanks again, not only the best theme, but also the best support.
cheers
Darryl