• Resolved dfcdev

    (@dfcdev)


    hello,

    how do i display a different site logo on a particular product category and its product pages?

    • This topic was modified 4 years, 9 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • I would suggest looking at the theme you’re using and seeing if you have theme options for a custom header. This would be a great place to start.

    Thread Starter dfcdev

    (@dfcdev)

    there is no option for a custom header, anyway of coding this?

    Thread Starter dfcdev

    (@dfcdev)

    ok i found a workaround and actually MORE than a workaround for this topic, so i thought i would share this with the community in case anyone needs help with this!

    So basically the following code, when added to your child theme functions.php file, passes the parameter of the product category slug onto the <body> tags of your theme template, what this allows you to do is to uniquely style any of your .css components per product/blog/page categories, pretty cool too! see code below and feel free to email me for any clarification:

    function woo_custom_taxonomy_in_body_class( $classes ){
    $custom_terms = get_the_terms(0, ‘product_cat’);
    if ($custom_terms) {
    foreach ($custom_terms as $custom_term) {

    // Check if the parent category exists:
    if( $custom_term->parent > 0 ) {
    // Get the parent product category:
    $parent = get_term( $custom_term->parent, ‘product_cat’ );
    // Append the parent class:
    if ( ! is_wp_error( $parent ) )
    $classes[] = ‘product_parent_cat_’ . $parent->slug;
    }

    $classes[] = ‘product_cat_’ . $custom_term->slug;
    }
    }
    return $classes;
    }

    add_filter( ‘body_class’, ‘woo_custom_taxonomy_in_body_class’ );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘site logos on product categories’ is closed to new replies.