carbon-fields icon indicating copy to clipboard operation
carbon-fields copied to clipboard

Metabox Position

Open zavaremre opened this issue 8 years ago • 6 comments

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' ) )

        ) ); 

}

zavaremre avatar Mar 24 '18 23:03 zavaremre

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.

atanas-dev avatar Mar 25 '18 09:03 atanas-dev

unfortunately not working

zavaremre avatar Mar 25 '18 14:03 zavaremre

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?

deqngeorgiev avatar Mar 30 '18 06:03 deqngeorgiev

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',
					) )
        ) ); 	
}

zavaremre avatar Mar 31 '18 17:03 zavaremre

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',
		) )```

deqngeorgiev avatar Apr 02 '18 07:04 deqngeorgiev

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/

zavaremre avatar Apr 02 '18 18:04 zavaremre