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
1 Answer
Reset to default 1You 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.
}