How can I jump to the first sub menu item of a top menu item in WordPress?

15 views Asked by At

I have a WordPress site with a top menu, and some top menu entries have sub menus, like this:

top1
top2
top3
   sub1
   sub2
   sub3
top4
top5

subs 1, 2 and 3 are sub menus of top3. top3 is actually empty, it just serves as a container for its 3 subs. I'd like to navigate automatically to sub1 when top3 is clicked.

I know that there's a solution for this, I've seen it many years ago but can't remember where...just a tiny snippet in functions.php.

Tried a shortcode with wp_redirect, but it doesn't work:

function goto_adresse_function() { 
    if (!is_admin()) {
        wp_redirect( 'kontakt/adresse');
    }
  }

add_shortcode('goto_adresse', 'goto_adresse_function');
0

There are 0 answers