Support

Account

Home Forums Backend Issues (wp-admin) Trying to add field group to the WooCommerce 'Shop' page (only) Reply To: Trying to add field group to the WooCommerce 'Shop' page (only)

  • Thanks @dangercode. I wanted the exact same thing. I used the docs and cheated by looking at your version. Here’s mine, a little shorter mostly bc of the closure.

    add_filter( 'acf/location/rule_values/page_type', function ( $choices ) {
        $choices['woo_shop_page'] = 'WooCommerce Shop Page';
        return $choices;
    });
    
    add_filter( 'acf/location/rule_match/page_type', function ( $match, $rule, $options ) {
        if ( $rule['value'] == 'woo_shop_page' )
        {
            if ( $rule['operator'] == '==' )
                $match = ( $options['post_id'] == wc_get_page_id( 'shop' ) );
            if ( $rule['operator'] == '!=' )
                $match = ( $options['post_id'] != wc_get_page_id( 'shop' ) );
        }
        return $match;
    }, 10, 3 );