1

I'm looking to edit a custom post type's menu link in the WordPress admin - Is this possible?

For example, currently its

/wp-admin/edit.php?post_type=application

and I want to update this with

/wp-admin/edit.php?s&post_status=all&post_type=application&cat=36&paged=1

Thank you for your time

1
  • No clue if possible at all but you can play around with this online tool. Just curious, WHY? Or look here
    – Charles
    Jun 19, 2018 at 14:29

2 Answers 2

1

You can use the admin_menu hook. You will be able to loop over all menus.

add_action( 'admin_menu', 'wpse_306432_edit_post_type_admin_menu', 11);
function wpse_306432_edit_post_type_admin_menu()
{
    global $menu;

    foreach($menu as $k => $v){
        if($v[1] == 'edit_applications') // possibly 'edit_application', I'm not sure
        {
            $menu[$k][2] = 'edit.php?post_status=all&post_type=application&cat=36&paged=1'; // I modify your query
            break;
        }
    }
}

Should work for you :)

Don't hesitate to add a nice :

echo '<pre>';
var_dump($menu);
echo '</pre>';
die();

After global $menu to understand how it works, and change more !

0

Thanks for your answer :) That looks like a better solution that what i've come up with!

I've added javascript to the admin and updated the link that way

function custom_admin_js() {
$url = get_bloginfo('template_directory') . '/library/js/wp-admin-XXX.js';
if( current_user_can( 'XX' ) ){ 
    echo '"<script type="text/javascript" src="'. $url . '"></script>'";
}; } add_action('admin_footer', 'custom_admin_js');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.