• I display a menu depending on a the value of a custom field in the post/page, as outlined here. The effect is having different sections in the site, and being presented a menu relevant to that section.

    However, it is often desirable for a specific page to be included in many menus (or sections). The problem is that the custom field will choose the menu. Now, I could setup a repeating-key custom field with many values – one for each section in which that page can be shown. The preferred menu to display should be the one in the same section as the last page viewed.

    One solution is to set a session variable in which you store something like ‘last-used-menu’. Then, when a page is being displayed, to check the custom fields for a specific key to see if any one value matches the last-used-menu, and allow it to take preference. If none match, then use the first correctly keyed custom field.

    Can I use sessid’s in WordPress? Is there a more elegant way?

  • The topic ‘Dynamic assigning of menus to displayed post/page’ is closed to new replies.