rwmb_show error
-
Hello, I am trying to use the rwmb_show filter, seeing that it does not work, I have replicated the example that you have on the documentation page but it does not work either, it returns this error:
Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed in /Users/jupa/Local Sites/wordpress/app/public/wp-includes/class-wp-hook.php on line 326 and exactly 2 expected in /Users/jupa/Local Sites/wordpress/app/public/wp-content/themes/naked/includes/custom-metaboxes.php:128 Stack trace: #0 /Users/jupa/Local Sites/wordpress/app/public/wp-includes/class-wp-hook.php(326): {closure}(true) #1 /Users/jupa/Local Sites/wordpress/app/public/wp-includes/plugin.php(205): WP_Hook->apply_filters(true, Array) #2 /Users/jupa/Local Sites/wordpress/app/public/wp-content/plugins/meta-box/inc/meta-box.php(75): apply_filters(‘rwmb_show_event…’, true, Array) #3 /Users/jupa/Local Sites/wordpress/app/public/wp-content/plugins/meta-box/inc/meta-box.php(57): RW_Meta_Box->is_shown() #4 /Users/jupa/Local Sites/wordpress/app/public/wp-content/plugins/meta-box/inc/meta-box-registry.php(19): RW_Meta_Box->__construct(Array) #5 /Users/jupa/Local Sites/wordpress/app/public/wp-content/plugins/meta-box/inc/core.php(32): RWMB_Meta_Box_Registry->make(Array) #6 /Users/jupa/Local Sites/wordpress/app/public/wp-includes/class-wp-hook.php(324): RWMB_Core->register_meta_boxes(”) #7 /Users/jupa/Local Sites/wordpress/app/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #8 /Users/jupa/Local Sites/wordpress/app/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #9 /Users/jupa/Local Sites/wordpress/app/public/wp-settings.php(695): do_action(‘init’) #10 /Users/jupa/Local Sites/wordpress/app/public/wp-config.php(112): require_once(‘/Users/jupa/Loc…’) #11 /Users/jupa/Local Sites/wordpress/app/public/wp-load.php(50): require_once(‘/Users/jupa/Loc…’) #12 /Users/jupa/Local Sites/wordpress/app/public/wp-admin/admin.php(34): require_once(‘/Users/jupa/Loc…’) #13 /Users/jupa/Local Sites/wordpress/app/public/wp-admin/post.php(12): require_once(‘/Users/jupa/Loc…’) #14 {main} thrown in /Users/jupa/Local Sites/wordpress/app/public/wp-content/themes/naked/includes/custom-metaboxes.php on line 128
And this is my testing code
add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) { $meta_boxes[] = [ 'title' => 'Event details', 'id' => 'event-details', 'post_types' => 'page', 'fields' => [ [ 'name' => 'Date and time', 'id' => 'datetime', 'type' => 'datetime', ], 'Location', [ 'name' => 'Map', 'id' => 'map', 'type' => 'osm', 'address_field' => 'location', ], ], ]; return $meta_boxes; } ); add_filter( 'rwmb_show_event-details', function( $show, $meta_box ) { $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; if ( $post_id === 123 ) { $show = false; } return $show; } );
I need to show some custom fields only on the home page and I would like to limit them by page id.
Thank you very much for any help you can give me.
- You must be logged in to reply to this topic.