I want to have a custom button in my post editor, but everything I find online is for the previous, classic editor of WordPress and none of them seem to work with the new Gutenberg thing.
Red mark is where I want it to be. Either on top, alongside "Publish" and others, or inside a metabox:
I tried:
add_action( 'edit_form_top', 'custom_button');
add_action( 'media_buttons_context', 'custom_button' );
add_action( 'post_submitbox_misc_actions', 'custom_button' );
add_action( 'post_submitbox_minor_actions', 'custom_button' );
add_action( 'post_submitbox_start', 'custom_button' );
where custom_button
just echo
s a simple HTML element (button or link):
function custom_button(){
$html = '<a>Do Something</a>';
echo $html;
}
What is wrong here? Is it something not supported in Gutenberg? Or do I need to set priorities on the add_action
(I want to add this button from a plugin, not functions.php
).
Are there any alternatives to this?