最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

actions - How can I prevent a function from loading in the admin screens?

programmeradmin1浏览0评论

When I add this code to my theme's functions.php file, it crashes my admin panel. How can I prevent it from loading in the admin screens?

//add_action('init', 'hekim_sticky_header'); 
// I want load this only if it is not admin panel

When I add this code to my theme's functions.php file, it crashes my admin panel. How can I prevent it from loading in the admin screens?

//add_action('init', 'hekim_sticky_header'); 
// I want load this only if it is not admin panel
Share Improve this question edited Jun 16, 2020 at 2:53 Pat J 12.4k2 gold badges28 silver badges36 bronze badges asked Jun 16, 2020 at 1:24 Javascript Asking AccountJavascript Asking Account 51 bronze badge 1
  • Need a lot more details, what is it doing, etc. – Tony Djukic Commented Jun 16, 2020 at 1:42
Add a comment  | 

1 Answer 1

Reset to default 1

You can use the is_admin() function to check:

add_action( 'init', 'hekim_sticky_header' );
function hekim_sticky_header() {
    if ( is_admin() ) {
        return;
    }
    // Rest of your function goes here.
}
发布评论

评论列表(0)

  1. 暂无评论