Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Ryan Ray

    (@ryanr14)

    Hi @mpdesigner11,

    Could you perhaps give us an outline with some more detail on what you are wanting to change in a header per product? Is this just an image or text or more? 🙂

    Thanks for giving us more clarity to figure out what’s possible here.

    Thread Starter mpdesigner11

    (@mpdesigner11)

    Hi ryanr14,

    Thanks for the response! At this point it’s just a logo change. My client has two separate product categories and they’d like to brand them differently. I was able to create a separate header for one of the brands and reference it (header-project.php) and have created another header (header-company.php), but just need some guidance on how and where to put the conditional statement based on product type?

    Cheers,
    mp 🙂

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @mpdesigner11 In the example you gave, the has_term check is where you would put the slug of the product category you’d like to display the custom header for. Then in the get_header function, you would put either project or company to query the proper header.

    Thread Starter mpdesigner11

    (@mpdesigner11)

    Thanks @jessepearson – appreciate the feedback!

    Just a quick follow up, where would I put that code? Function.php? Single-Product?

    Cheers,
    mp

    jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @mpdesigner11 It would go in functions.php .

    Thread Starter mpdesigner11

    (@mpdesigner11)

    Fantastic, thank you @jessepearson

    Thread Starter mpdesigner11

    (@mpdesigner11)

    SOLUTION:

    This function wasn’t working in Functions.php – because of the theme’s custom Single-Product.php implementation.

    I replaced get_header ( ‘shop’ ) in single-product.php with:

    if ( is_product() ) {
    if ( has_term( ‘bracelets’, ‘product_cat’ ) ) {
    get_header(‘project’);
    } elseif ( has_term( ‘jewelry’, ‘product_cat’ ) ) {
    get_header(‘project’);
    } elseif ( has_term( ‘cards’, ‘product_cat’ ) ) {
    get_header(‘company’);
    } elseif ( has_term( ‘t-shirts’, ‘product_cat’ ) ) {
    get_header(‘company’);
    }
    }

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Conditional Header on Single Product Page’ is closed to new replies.