Open valexxas opened 10 months ago
I will supplement it.
Conditions: child page, condition for fields "->where( 'post_level', '=', 1 )
" ( only the first level, not child ones), fields should not be output.
What happens: the CarbonFields fields are output, the input values are not saved. On the pages of the first level, the fields are displayed, their values are saved.
Removing the condition "->where( 'post_level', '=', 1 )
". Result: fields are displayed everywhere, all values are saved as they should be.
After experimentation, the problem was circumvented by a similar condition:
Container::make( 'post_meta',__( 'Meta fields' ) )
->where( 'post_type', '=', 'page' )
->where( 'post_level', 'CUSTOM', function( $post_level ) {
return ( $post_level == 2 );
} )
// OR
->where( 'post_parent_id', 'CUSTOM', function( $post_parent_id ) {
return ( $post_parent_id == wc_get_page_id( 'shop' ) );
} )
Version
Expected Behavior
Output meta fields only on child pages for the specified specific page
Actual Behavior
The nesting level and parent page are not defined. If the condition is
->where( 'post_parent_id', '=', 0 )
, then the fields will be displayed on all pages, including on child pages (having a parent page). Also, when using->where( 'post_level', '=', 0 )
, the field is always output, including on child pages. When specifying->where( 'post_level', '=', <ANY_NUMBER>)
or->where( 'post_parent_id', '=', <ID_PARENT_PAGE> )
the fields are not output anywhere.Container definition
Comments
I'm sorry, I'm using a translator to communicate with you. There may be problems with the translation of phrases.