admin管理员组文章数量:1200976
Excuse me if something like this has been asked before. So, I'm trying to alter the query which displays the posts of a custom post type, but on the admin side, more precisely, the edit.php page. This is my code:
function my_function() {
global $pagenow, $typenow;
if( 'edit.php' == $pagenow && 'certain-post-type' === $typenow ) {
// do something
}
}
add_action( 'admin_init', 'my_function' );
The main problem is not altering the query itself (yet!), but targeting only the edit.php page which lists the custom-post-type posts. It works when I hook onto the admin_init
hook, but I understand that admin_init
runs on every admin page load, which seems a bit unnecessary. I tried limiting this to fire only on the edit.php page for the custom post type by setting the hook to
add_action( 'load-edit.php', 'my_function' );
, but this did nothing.
Couldn't find much documentation on the load-{$pagenow}
hook, hopefully the community can steer me in the right direction and tell me what I did wrong?
本文标签: hooksLimiting actions only to editphp page for specific custom post type
版权声明:本文标题:hooks - Limiting actions only to edit.php page for specific custom post type 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738574850a2100814.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论