Support

Account

Home Forums Front-end Issues ACF WYSIWYG in WooCommerce Cat pages

Helping

ACF WYSIWYG in WooCommerce Cat pages

  • Hello,

    In order to optimize the WooCommerce Archive pages I wanted to add an additional WYSIWYG box that displays text below the products. During a Google search I came across this post that explains how to do this.

    However I noticed that when visiting the WooCommerce Shop page (which is an archive page) the following error is shown;

    Notice: Undefined property: WP_Post_Type::$term_id in /app/public/wp-content/themes/theme-name/class-theme-name-woocommerce.php on line 121

    What I did to remedy this is add a conditional statement to the code from the original post;

    if ( is_shop() ) 
        return;
    } else {
        $term_id = get_queried_object()->term_id;
        .....
        .....
    }

    And in order to get rid of the WPCS nagging me about escaping on output I added
    echo wp_kses_post( $custom_field );

    Now for my questions:
    1: Does adding the if ( is_shop ) ) make any sense to get rid of the error notice on the frontend?
    2: Is the method described in the post (still) valid or is it outdated?
    3: Does escaping the output make any sense or am I overly protective? The only person who will add content to the ACF WYSIWYG field will be me.

    And for clarity, I choose to display the ACF output via the WC hooks method and not adding the actual template file to my theme. And to accomplish this I am using ACF Pro, not the free version, if that would make any difference in how to handle this specific task!?

    Thanks in advance to anyone that is willing to school an ACF noob!

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘ACF WYSIWYG in WooCommerce Cat pages’ is closed to new replies.