I have a site that is pretending to be three sites. This is done by a series of conditional statements and page templates to make it look like the user is on a different site depending on their menu choice.

The client wants it to remember the last 'site' the user was on so they are taken back there if they come back. For example, the three 'sites' are home, autos, advertising, so if the user was on the 'autos' part of the site, when they come back, they're taken back to autos. The three sites are in a menu that was created by the custom menus option under Appearance > Menus.

I think this question is the same thing I'm asking for, but the entire discussion and the tutorials posted are completely over my head.

Doe anyone have the actual code I need to input and where? Or can point me to a tutorial to help me understand how to do it myself?

Thanks much!

  • Are users logged into the site or are all pages of the site public? That will determine which way we can do this. Let us know! – Tom Feb 18 '12 at 22:32

Unfortunately, since we aren't able to see any of your current code, and it's sort of a vague description of your implementation, it'll be difficult for anyone to post actual code that will work for you.

But to point you to some resources that might help, you might find these helpful:

  • I'm happy to be more specific... what do you need to see? This is the menu I'm trying to affect: <div id="menu"> <?php wp_nav_menu( array('menu' => 'Main Navigation', 'theme_location' => 'main' )); ?> </div> – m.j. Feb 18 '12 at 23:56

Shame you didn't find an answer to this, I have exactly the same problem!

The solution I'm leaning towards is to set a custom class and ID value to the menu options that I want to set cookies, for example:

  • class="set_cookie" id="site_1"
  • class="set_cookie" id="site_2"
  • class="set_cookie" id="site_3"

Then write a little jquery script which goes, (caution, sudo-code, not necessarily valid):

$( document ).ready() {
    $( ".set_cookie" ).onclick() {
        var site =  $( this ).attr("id");
        set_cookie( site );
        return true;

... obviously the set_cookie() function would have to exist, or be written, but something like that should capture the click, and register the "site" value before changing page.

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.