Front end only version of Init hook?
conditional-statements, wordpress
Solution
Wrap up your action's hooks and function in an `if(!is_admin()){}`
Like so :
if(!is_admin()) {
//Style
add_action('init', 'style');
function style()
{
wp_enqueue_style('style', THEMEROOT . '/css/your.css');
}
}
Problem
I'm trying to build a feature into my theme that relies on doing things before the headers are sent. So naturally I hooked into the Init hook like so: ``` add_action('init', 'my_function'); ``` But the problem is that I only want my_function to run if the user is not looking at the admin section or the login page. So what hook can I use that is front-end only but is run before the headers are sent. Looking at the API reference, there doesn't appear to be any, and obviously conditionals don't work that early in the runtime. So other than searching the URL for /wp-admin/ and /wp-login/ (which seems clunky to me) I can't figure it out.