• hi.
    I want the logo in all thr posts to link to the category page.
    I know how to do it manuly for every category.
    is there a way to do it to all the categories?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    I’m not sure I understand what you mean.

    Are you trying to make the site header logo’s link point to the category of the current post for ALL the posts throughout the site?

    If yes, for posts that have multiple categories, how do you determine the category to be used for linking? Or are all post using 1 category only?

    Let us know.

    Thread Starter shaygen

    (@shaygen)

    yes
    I will make all the posts with only one category

    Try adding this PHP snippet:

    add_filter( 'generate_logo_href', function( $href ) {
        $post_category = get_the_category( get_the_ID() );
    
        if( is_single() ){
            $current_post_cat_link = get_term_link( $post_category[0]->term_id, $post_category[0]->taxonomy );
            return $current_post_cat_link;
        } else { 
    		return $href; 
    	}
    
    } );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘link logo in posts to the category’ is closed to new replies.