用户是否已登录并允许删除此帖子类型的帖子?里面有三张支票get_delete_post_link
在任何事情发生之前的功能:
if ( !$post = get_post( $id ) )
return;
$post_type_object = get_post_type_object( $post->post_type );
if ( !$post_type_object )
return;
if ( !current_user_can( $post_type_object->cap->delete_post, $post->ID ) )
return;
我猜这是你的第三次检查失败了。您可以将它们粘贴到代码中并替换
return;
使用调试代码查看发生了什么:
if ( !$post = get_post( $id ) ) {
echo \'could not get post. \';
} else {
echo \'got post. \';
}
$post_type_object = get_post_type_object( $post->post_type );
if ( !$post_type_object ){
echo \'could not get post object. \';
} else {
echo \'got post object. \';
}
if ( !current_user_can( $post_type_object->cap->delete_post, $post->ID ) ){
echo \'user does not have proper capability. \';
} else {
echo \'user is ok to delete this post. \';
}