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 );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.