Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #503573

    Hi

    All posts on my site have the header “Blog – Latest News” regardless of settings. I’d like the header to be the name of the category it is in, ie News, Events etc etc.

    Thanks.

    • This topic was modified 9 years, 5 months ago by ian_clarke.
    #503575
    #503580

    Hi ian_clarke!

    Add this to the bottom of your functions.php file.

    add_filter('avf_title_args', 'fix_single_post_title', 10, 2);
    function fix_single_post_title($args,$id)
    {
        if ( $args['title'] == 'Blog - Latest News' )
        {
            $categories = get_the_category();
            if ( !empty($categories) ) { $args['title'] = $categories[0]->name; }
        }
    
        return $args;
    }

    Best regards,
    Elliott

    #503581

    Thanks for the quick reply Yigit.

    Nearly there, what would I need to change to display the category name instead of the post title?

    #503584

    Brilliant, combined the two and got exactly what i was after.

    Many thanks guys.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Change post header to category name’ is closed to new replies.