Forums

get_post_type() and WooCommerce (1 post)

  1. piglesias
    Member
    Posted 2 months ago #

    Hi!

    I'm developing a site + store using Canvas theme and Woocommerce.

    Now, I'm trying to implement Zopim live chat just in store and regular pages (not into the blog). In the previous version of this site running WP-Commerce I did it using this code in the footer.php:

    <?php if ( is_page('') | is_post_type('wpsc-product') ) {?>
    
    <!--here goes the chat javascript-->
    
    <?php }?>

    Well, If I try this in woocommerce:

    <?php if ( is_page('') | is_post_type('product') ) {?>
    
    <!--here goes the chat javascript-->
    
    <?php }?>

    It breaks at is_post_type('').

    So I tried via get_post_type() and a filter in the functions.php file:

    add_action( 'woo_footer_after', 'closefooterwrap', 10 );
    
    function closefooterwrap () {
        echo '</div>';
      $tipo = get_post_type();
        if ( is_page() | $tipo == 'product' ) {
        	get_template_part('chat-code');
        	}
    
       }

    But get_post_type(); retursns 'product' type almost everywhere in the site! Even in blog post! So the chat displays everywhere. :-(

    Anybody has got any idea about how to solve this?

    Thank you very much in advance.
    Regards.

    Pablo

Reply

You must log in to post.

About this Topic