WordPress menu: have first element selected by default

I have an Archive page with a WordPress menu on top. This menu leads to the categories chosen by the editors to be featured. I have set it up already, but there’s one thing that I haven’t found how to do.

When I land in the page, no category is selected in the menu, so I display no content. Only when users click on a menu item, and the same page is loaded with a selected category, then I display the content (child categories and posts belonging to that category). So my question is, is there a way to pre-populate/select the first item in the menu if nothing is selected? I know the implications are many, not only I need the item selected, but I need WP_Query to be aware of that selection. The easiest workaround is to include the category in the navigation link that leads to this page. But as I said, the menu is dynamic and I have no way to know which element is the first in this category menu. Also, I’d rather not add a category in the URL to the archive, it’d look odd and SEO wise it’d have some effects too.

Any ideas?

Read more here:: WordPress menu: have first element selected by default

Leave a Reply

Your email address will not be published. Required fields are marked *