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 need to show some part of the page only once, based on cookies. The main problem that I can set cookies only in plugin, hooking init action.

I've read 20 pages of google, this site, asked 2 forums, but I still have this problem. Any help would be appreciated!

share|improve this question
    
Chip Bennett is right - you can hook also via init. and can you specify exactly what is the problem of your "logic" ? I have used this method in functions.php more than once . functions.php and plugins are essentially the same, the only difference (as far as you concern) is the loading sequence . –  krembo99 Dec 13 '11 at 5:19
add comment

2 Answers

Why do you think you can only hook into init via Plugin, rather than via the Theme?

The setup_theme hook, which fires when the Theme is setup, fires before the init hook. Thus, a Theme is perfectly capable of hooking into init.

share|improve this answer
add comment

Well, i'm not sure, that you get the idea.

I need to make some kind of a logic:

if (!isset($_COOKIE['mycookie'])
{
    echo 'Hi, anon!';
    setcookie('mycookie', 1, time()+60*60*24;
}

I can't make this functionality using plugins=(

share|improve this answer
    
Please do not use answers for discussion. Comment on answers or edit details into your original question. You might want to register on site so system recognizes you properly (otherwise you might be treated as different accounts and not have proper access to your question). –  Rarst Oct 2 '11 at 10:36
add comment

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.