Horje
Custom Logo for Different WooCommerce Categories - Wordpress Solution
Basically, I'm trying to figure how to use conditional tags to change the logo for certain categories on my site. I have a main logo but for category "shirt" for example, I would want another logo shown for instance. I know the answer is probably easy but can't seem to Google what I'm looking for, which is why I'm posting here. Here's the code in my template where logo appears:


                <?php


                // show logo


                $logo = porto_logo();


                echo $logo;


                ?>

That's pretty much all I got for right now. Thanks for any assistance you can give me.

Solution - 1

for category page, this should work

<?php 

$logo = porto_logo();
if ( is_product_category() ) {

if ( is_product_category( 'test' ) ) {
echo 'HTML';
} elseif ( is_product_category( '2' ) ) {
echo 'HTML';
} else {
echo $logo;
}

}

?>	
but you need something else on the product page... is_product_category() will return false there... You can add is_product() to check if it's product page... then use has_term to check for product categories. https://codex.wordpress.org/Function_Reference/has_term
<?php 

$logo = porto_logo();
if ( is_product_category() || is_product() ) {

if ( is_product_category( 'test' ) || has_term( 'test', 'product_cat'  )) {
echo 'test';
} elseif ( is_product_category( '2' ) || has_term( '2', 'product_cat' ) ) {
echo '2';
} else {
echo $logo;
}

}

?>	


Solution - 2

Good afternoon, Firstly, we need to see the code of porto_logo() in order to see if there is some hook available there. I am going to look for this code into some porto theme.


Solution - 3

Are you using child theme ?? If you want I can code this for you.. Please let me know and contact me at - [email protected]





Wordpress

Related
Page Animations - Wordpress Solution Page Animations - Wordpress Solution
Formidable Form Copying Repeater Sections Values to Another Repeater Section Fields. - Wordpress Solution Formidable Form Copying Repeater Sections Values to Another Repeater Section Fields. - Wordpress Solution
Add custom fields to my woocommerce completed email - Wordpress Solution Add custom fields to my woocommerce completed email - Wordpress Solution
Gallery Attachment Pagination X images per page - Wordpress Solution Gallery Attachment Pagination X images per page - Wordpress Solution
Plugin (?) issues after hosting migration. 500 error, cannot get on site or wp-admin. - Wordpress Solution Plugin (?) issues after hosting migration. 500 error, cannot get on site or wp-admin. - Wordpress Solution

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
14