• Resolved Antrock

    (@antrock)


    I am trying to use Widget Logic to display a widget only on posts withing a certain category. As far as I am aware is_single() && in_category( 'x' ) should work.

    As I am trying to use this on a WooCommerce page i am using is_single() && in_product_category( 'x' ) but I get an error saying

    Call to undefined function in_product_category() in /home/*/wp-content/plugins/widget-logic/widget_logic.php(284) : eval()’d code on line 1

    .

    I also tried is_product() but it just seems that it won’t accept the in_product_category line as I get the same error (is_product_category works fine but I don’t need it here). Any ideas how I can fix this? I need this badly as there are many categories of products that need different informations and manuals on the sidebar!

    http://wordpress.org/plugins/widget-logic/

Viewing 5 replies - 1 through 5 (of 5 total)
  • you may need to change the ‘load logic’ point to a later point to ensure the woo_commerce plugin has loaded before the logic is invoked.

    http://wordpress.org/plugins/widget-logic/installation/
    http://wordpress.org/plugins/widget-logic/screenshots/

    Thread Starter Antrock

    (@antrock)

    I tried every setting there and the same error showed up every time. My default setting is/was ‘when all PHP loaded’ anyway. Any other idea?

    Thread Starter Antrock

    (@antrock)

    Still haven’t found a solution to this. Why would in_product_category break Widget Logic?

    Logic is_single() && in_product_category( 'x' ) || is_post_type_archive() || is_product_category( 'x' ) breaks Widget Logic on products pages even if they are not in product category X (are in product category Y). Same happens if i use is_product() && in_product_category( 'x' ). If I use in_product_category( 'x' ) it is broken everywhere.

    What could be the cause of this?

    are you sure there’s an in_product_category function? There’s is_… but not in_… that I can see here under functions…

    http://docs.woothemes.com/wc-apidocs/

    Thread Starter Antrock

    (@antrock)

    Alan you were right. I automaticly assumed there must be a function in_product_category (still think there should be one! 🙂 ). I finally got it to work with is_single && has_term( 'x', 'product_cat' ).

    Thank you for this great plugin!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Widget on posts within a certain category’ is closed to new replies.