Changing the header on post listing page in admin area

I want to display my custom menu in custom post listing page under the title of custom post type.

For example there are post type and one small icon on custom post type listing page as well as add/edit custom post type page.

Read More

Under that icon I want to add my custom menu from my custom plugin.

snapshot

Can I add my menu at that place?

One more thing is that can I add “Cancel” link to the add/edit page for go to listing page?

Related posts

Leave a Reply

1 comment

  1. To insert links at that position, you need the filter views_edit-POST_TYPE, replacing POST_TYPE by the slug of your CPT.

    Example:

    add_filter( 'views_edit-portfolio', 'custom_list_link_wpse_79975' );
    
    function custom_list_link_wpse_79975( $views ) 
    {
        $views['dashboard'] = '<a href="' . admin_url('index.php') . '">Dashboard</a>';
        // $views['another-view'] = '<a href="#">Contact</a>';
        return $views;
    }
    

    Results in:
    views edit cpt


    The second question should have been a separate Q, but while we at it…

    You could create your own meta box, but there’s a couple of useful hooks:

    // Another possible action hook is: post_submitbox_start
    add_action( 'post_submitbox_misc_actions', 'custom_publish_link_wpse_79975' );
    
    function custom_publish_link_wpse_79975() 
    {
        // check for post type
        global $current_screen;
        if( 'portfolio' != $current_screen->post_type )
            return;
    
        echo '<div class="misc-pub-section my-link">
            <a href="' . admin_url('edit.php?post_type=portfolio') . '">Cancel</a>
            </div>';
    }
    

    Which results in:

    cancel in publish meta box