0

I know how to use capabilities to remove the "Add New" functionality for a custom post type, but what I really need to do is change the target of those links. Does anyone know how I might go about doing that?

I would be an "external" link (to the front end of the website) and not a page on wp-admin.

1

in most of the case WordPress ui uses admin_url() function to retrieve administrative urls. so you can use admin_url filter to modify that.

Example:

apply_filters( 'admin_url', 'wpse_271288_change_add_new_link_for_post_type', 10, 2 );
function wpse_271288_change_add_new_link_for_post_type( $url, $path ){
    if( $path === 'post-new.php?post_type=your_custom_post_type' ) {
        $url = get_permalink(/*your post ID here*/); // or any other url
    }
    return $url;
}

Change your_custom_post_type with your custom post type name.

Reference (WordPress Version 4.8): edit.php (Line No. 312) and link-template.php (Line No. 3132)

  • 1
    glad it worked! don't forget to check user's role/permission before allow them to create/edit content from your custom form... :) – Kudratullah Jun 25 '17 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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