Metabox Position
Version
- Carbon Fields:2.2.0
- WordPress:4.9.4
- PHP:
Metabox I could not adjust your positions.
->set_priority( 'high' ) ->set_context( 'advanced' )
The codes at the top did not work.
add_action( 'carbon_fields_register_fields', 'crb_attach_post_meta' );
function crb_attach_post_meta() {
Container::make( 'post_meta', __( 'Post Options' ) )
->set_priority( 'high' )
->set_context( 'advanced' )
->where( 'post_type', '=', 'post' )
->add_fields( array(
Field::make( 'media_gallery', 'patika_post_gallery' )
->set_type( array( 'image' ) )
) );
}
Hi @zavaremre ,
I believe the 'advanced' context is the default value so that won't change anything. As for the priority, if you have other meta boxes (from plugins or Carbon Fields) that use the 'high' priority it is also possible that your container may not appear to be affected as both will be with equal priority.
Try using the following code which will move your container between the title and the text editor as a test:
->set_context('carbon_fields_after_title');
Note: In the future, please follow the full Issue Template when submitting issues.
unfortunately not working
Hi @zavaremre ,
I've tested the ->set_context('carbon_fields_after_title'); and it works as expected.
Can you provide, please, more details about the issue and what you want to achieve?
I want you to stand at the top on the right.
<?php
use Carbon_Fields\Field;
use Carbon_Fields\Container;
add_action( 'carbon_fields_register_fields', 'patikapagetitlesettingsmetabox' );
function patikapagetitlesettingsmetabox() {
Container::make( 'post_meta', __( 'Display Page Title','patika' ), 'Display Page Title' )
->where( 'post_type', '=', 'page' )
->set_priority( 'high' )
-> set_context ( ' carbon_fields_after_title ' )
->add_fields( array(
Field::make( 'radio', 'patika_disabled_page_title' )
->set_default_value ('Show')
->add_options( array(
'Show' => 'Show',
'Hide' => 'Hide',
) )
) );
}
To display the field at the top on the right you should use set_context( 'side' ) and set_priority( 'high' )
Container::make( 'post_meta', __( 'Display Page Title','patika' ), 'Display Page Title' )
->where( 'post_type', '=', 'page' )
->set_priority( 'high' )
->set_context ( 'side' )
->add_fields( array(
Field::make( 'radio', 'patika_disabled_page_title' )
->set_default_value ('Show')
->add_options( array(
'Show' => 'Show',
'Hide' => 'Hide',
) )```
first we need to reset the default positions. I reverted to the default with the underlying plugin. now working
https://wordpress.org/plugins/reset-meta-box-positions/