Specific Header Image for specific Category archive page… How??

  • sghegde87

    #8115

    Hi,

    There are 6 Categories in my website. I have made each category archive to be a separate page.

    Now, How do I set a different banner (header) image for each one of them??? Not the Random way.. I want a specific header image on each Category archive..

    For Ex:

    Category archive 1:- Banner1

    Category archive 2:- Banner 2

    ………

    ……….

    Category archive 6:- Banner 6.

    Pardon me if this has been answered somewhere. Searched it but couldn’t find…

    Prasanna SP

    #40383

    Try something like this,

    function graphene_custom_category_header_img($header_img) {
    if( is_category() ) {
    $cat_ID = get_query_var('cat');

    switch( $cat_ID ) {
    case 12: $header_img = 'http://path_to_image_for_category_ID_12.jpg';
    break;

    case 23: $header_img = 'http://path_to_image_for_category_ID_23.jpg';
    break;

    case 34: $header_img = 'http://path_to_image_for_category_ID_34.jpg';
    break;
    }
    }
    return $header_img;
    }
    add_filter( 'graphene_header_image','graphene_custom_category_header_img');

    You need to find out the ID of all the categories and then put it in switch case. Then change header image path with the one you want to use with that category archive page.

    sghegde87

    #40384

    Genius!! Works like a charm man…. Works like a CHARM!!! Really impressive and appreciable…. Thanks a lot…

    Marking this as resolved…..

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

You must be logged in to reply to this topic.