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.
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.
Share Improve this question asked Jun 25, 2017 at 16:17 EcksteinEckstein 1,1194 gold badges27 silver badges52 bronze badges1 Answer
Reset to default 1in 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:
add_filter( '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)