wplecturer.com
0 votes
18 views

How do you create a new menu location in WordPress?
in WordPress by (67.0k points) | 18 views

1 Answer

0 votes
Best answer

From

Navigation Menus

https://codex.wordpress.org/Navigation_Menus

  1. We Register Menus

First, in your theme's functions.php, you need to write a function to register the names of your menus. (This is how they will appear in the Appearance -> Menus admin screen.) As an example, this menu would appear in the "Theme Locations" box as "Header Menu".

  • function register_my_menu() { 
  • register_nav_menu('header-menu',__( 'Header Menu' )); 
  • add_action( 'init', 'register_my_menu' ); 

    And this would make two menu options appear, header menu and extra menu -

    • function register_my_menus() { 
    • register_nav_menus( 
    • array( 
    • 'header-menu' => __( 'Header Menu' ), 
    • 'extra-menu' => __( 'Extra Menu' ) 
    • ); 
    • add_action( 'init', 'register_my_menus' ); 

      2. We add to Theme

      • <?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?> 
        by (67.0k points)

        1.7k questions

        1.7k answers

        81.7k users

        6 Online Users
        0 Member 6 Guest
        Today Visits : 236
        Yesterday Visits : 1272
        Total Visits : 1895923
        Dear All, These are my answers from Quora and primarily Google; please check the answer and from others sites; the answers are free and without any liability.To make a decision, write down all of the positives and negatives on a piece of paper.Thank you, Elias Katsaniotis, MSc.
        1,653 questions
        1,658 answers
        81,738 users
        @ 2022 V Katsanioti ,All rights reserved