-1

I've tried this inside of my plugin ('init' hook) but it doesn't work:

if(is_front_page() || is_singular() || is_archive()) { ... }

How could I check it using init hook? Thanks.

4

init is too early for conditional tags to work. It marks when core finished loading, but no environment is set up yet.

For admin area only you can hook into admin_init.

For conditionals on front end earliest hook you can reliable use is template_redirect.

  • 1
    Is template_redirect executed before headers are send? Thanks. – thom Jul 26 '11 at 12:16
  • 1
    @thom yes, there should be no output before it. – Rarst Jul 26 '11 at 13:17
  • Rarst, thanks so much for this. You solved my problem by giving info on the template_redirect hook. now the is_page('page name') method works perfectly! – clockwiseq Apr 20 '13 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.