Gutenberg add a custom metabox to default blocks

Using filters we can modify the props and attributes of blocks. First we extend the attributes to include the new attribute: const { addFilter } = wp.hooks; // Register/add the new attribute. const addExtraAttribute = props => { const attributes = { …props.attributes, extra_attribute: { type: “string”, default: “default_value” } }; return { …props, attributes … Read more

How Does WordPress Remember Metabox Positions?

WordPress saves them in the databas in wp_usermeta as serilized array. For the dashboard all are registered in meta-box-order_dashboard if the meta-box(s) are in metaboxhidden_dashboard they will not be shown. The order will be as saved in database and if not in metaboxhidden_dashboard. Example the dashboard: KEY: meta-box-order_dashboard VALUE: Array ( [normal] => dashboard_right_now,dashboard_recent_comments,dashboard_incoming_links,dashboard_plugins [side] … Read more

How to add tab which is visible only in admin side of product in woocommerce? [closed]

I have worked on your issue and found a solution after some Google. Note: Add the below mentioned code to theme’s functions.php or any plugin’s file. Code: This filter function will add a custom tab to the Products Data metabox <?php add_filter( ‘woocommerce_product_data_tabs’, ‘add_my_custom_product_data_tab’ , 99 , 1 ); function add_my_custom_product_data_tab( $product_data_tabs ) { $product_data_tabs[‘my-custom-tab’] … Read more

Creating a metabox to upload multiple images

That depends entirely on what you mean by “attach.” Each WordPress post can already have multiple media attachments – photos, documents, etc. You upload these using the built-in uploader and they’ll all be marked as “attached” to that specific post ID. You can refer to these later programatically elsewhere. For example, the following code will … Read more

Best practices for meta box placement?

It is hard to declare best practices here. The placement depends on the content of the metabox: an editor field would be too narrow usually in the side column; two small checkboxes on the other hand will look lost in the main column. To understand where which box will be placed, let’s use a small … Read more

Make Custom Metaboxes Collapse by Default

To display a metabox collapsed or closed by default, it is good to know that adding closed to it’s class attribute will display it closed. All meta-boxes main divs that have closed in their classname, are displayed in the closed form. When the arrow is clicked it will be removed or added (toggled). This is … Read more

Remove the Yoast SEO Post Metabox [closed]

On remove_meta_box is a note: Because you can’t remove a meta box until it’s been added, it’s important to make sure your call to remove_meta_box() happens in the right sequence. WordPress SEO adds meta boxes on add_meta_boxes action with default priority – 10, which run after admin_init, so that won’t remove them. Instead you need … Read more

Remove the Featured Image Meta Box

I haven’t had time to test this but this looks like it should work for you. add_action(‘do_meta_boxes’, ‘remove_thumbnail_box’); function remove_thumbnail_box() { remove_meta_box( ‘postimagediv’,’post’,’side’ ); } Check this for more info. Edit: The main change here is that you need to attach the function to do_meta_boxes instead of admin_menu