New Landing How can we help? Themeforest Theme Support Dante Different logo per category post

Viewing 6 posts - 1 through 6 (of 6 total)
  • Posted in: Dante
  • #59483
    Brentnauer
    Member
    Post count: 65

    Hi there,

    How would I achieve having a different logo on a post page depending on the post’s category?

    I found the KB article about doing it per page ID and that’s working fine, but I want to enforce a specific logo across multiple posts in a single category.

    Thanks for your help

    #59503
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    Unfortunately you can’t do it per category as there isn’t a category class to call in the css like there is with a post or page.

    – Kyle

    #59505
    Brentnauer
    Member
    Post count: 65

    Is there a plugin that you know of that’s able to create a category class like that?

    #59517
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    No sorry

    Try a google search

    – Kyle

    #59521
    Brentnauer
    Member
    Post count: 65

    Figured it out. For anyone else who find this and wants to know how to do it, adding the below code to functions.php outputs the category slugs to the body class:

    // add category nicenames in body and post class
    function category_id_class($classes) {
    	global $post;
    	foreach((get_the_category($post->ID)) as $category)
    		$classes[] = $category->category_nicename;
    	return $classes;
    }
    add_filter('post_class', 'category_id_class');
    add_filter('body_class', 'category_id_class');
    #59594
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Cool, thanks for sharing the solution 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register