Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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