在wordpress admin中加载内容之前,有任何方法来获取post_type


Have any method to get post_type before load the contents in wordpress admin

我想在从数据库中获取数据之前获得post_type。我有办法得到它。我用的是:

add_action( 'admin_head', 'get_type' );

但是这个钩子在页面加载时不起作用。我还使用了:

global $current_screen; 

admin_init动作内。在帖子查询运行之前,是否有办法获得帖子类型?

您试过init了吗

add_action('init','my_post_type_func');

在WordPress完成加载后运行,但在发送任何头文件之前。