How to add a button to custom post type’s posts-page

You can add button via add_meta_box function.

function add_your_meta_box(){

add_meta_box('your-metabox-id', 'Title', 'function_of_metabox', 'custom_post_type', 'side', 'high');}

add_action('add_meta_boxes', 'add_your_meta_box'); 

function function_of_metabox()
{?>
    <input type="submit" class="button button-primary button-large" value="Add New" id="add-new"/>
<?php }

if you add to multiple post type, you should use foreach loop.

function add_your_meta_box(){

  $types = array("post","page","custom_post_type");

  foreach($types as $type){

    add_meta_box('your-metabox-id', 'Title', 'function_of_metabox', $type, 'side', 'high');}

}

add_action('add_meta_boxes', 'add_your_meta_box'); 

Leave a Comment