1

we have a website running on WPMU, and the main site is using Woo-commerce and the sub sites doesn't use that. I use conditional statement in my meta title with following code:

<title>
<?php if( is_product_category( 'cds' ) ) { ?>
CD
<?php } elseif ( is_product_category( 'dvds' ) ) {?>
DVD
<?php } else {?>
<?php wp_title( '|', true, 'right' ); ?>
<?php } ?>

but the thing is the sub sites, can not read this code, because the Woocommerce functions are undefined in those. I almost sure that there is no way to identify a Woocommerce product page by WP core conditional tags, Do you guys have any idea how can i identify them?

2
  • Wrap your code in is_main_site(), or better yet, function_exists( 'is_product_category' ) Commented May 24, 2014 at 19:07
  • @TheDeadMedic Works fine, Post it as an answer and i can mark it then. Commented May 27, 2014 at 15:51

1 Answer 1

1

You can rewrite you code as

        <title>
        <?php if (!function_exists( 'is_product_category' )) {
        if( is_product_category( 'cds' ) ) { ?>
        CD
        <?php } elseif ( is_product_category( 'dvds' ) ) {?>
        DVD
        <?php }
        }else { wp_title( '|', true, 'right' ); } ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.