I want to add a custom menu method to WordPress: Step 1: functions. php {code ...} step 2: page1.php {code ...} page2.php {code ...} page3.php {code ...} step 3: Go to the management background to set the corresponding menu, and the foreground will be displayed normally (after the menu is created... I want to add a custom menu for WordPress
Method:
Step 1: functions. php
If (function_exists ('register _ nav_menus ') {register_nav_menus (array ('nav1' => _ ('website navigation 1 '), 'nav2' => _ ('website navigation 2'), 'nav3' => _ ('website navigation 3 '),));} function wp_nav1_menu ($ class = 'nav1', $ location = 'nav1') {echo'
"," ", Preg_replace ("/
] *>
] *>/"," ", Wp_nav_menu (array ('theme _ location' => $ location, 'echo '=> false )))).'';} Function wp_nav2_menu ($ class = 'nav2', $ location = 'nav2') {echo'
"," ", Preg_replace ("/
] *>
] *>/"," ", Wp_nav_menu (array ('theme _ location' => $ location, 'echo '=> false )))).'';} Function wp_nav3_menu ($ class = 'nav3', $ location = 'nav3') {echo'
"," ", Preg_replace ("/
] *>
] *>/"," ", Wp_nav_menu (array ('theme _ location' => $ location, 'echo '=> false )))).'';}
Step 2: page1.php
Page2.php
Page3.php
Step 3: Go to the management background to set the corresponding menu, and the foreground will be displayed normally (after the menu is created)
Problem:
An error occurred while creating nav4 on the page4.php page following the above steps:
Fatal error: Call to undefined function wp_nav4_menu () in /...... /Page4.php on line x
Reply content:
I want to add a custom menu for WordPress
Method:
Step 1: functions. php
If (function_exists ('register _ nav_menus ') {register_nav_menus (array ('nav1' => _ ('website navigation 1 '), 'nav2' => _ ('website navigation 2'), 'nav3' => _ ('website navigation 3 '),));} function wp_nav1_menu ($ class = 'nav1', $ location = 'nav1') {echo'
"," ", Preg_replace ("/
] *>
] *>/"," ", Wp_nav_menu (array ('theme _ location' => $ location, 'echo '=> false )))).'';} Function wp_nav2_menu ($ class = 'nav2', $ location = 'nav2') {echo'
"," ", Preg_replace ("/
] *>
] *>/"," ", Wp_nav_menu (array ('theme _ location' => $ location, 'echo '=> false )))).'';} Function wp_nav3_menu ($ class = 'nav3', $ location = 'nav3') {echo'
"," ", Preg_replace ("/
] *>
] *>/"," ", Wp_nav_menu (array ('theme _ location' => $ location, 'echo '=> false )))).'';}
Step 2: page1.php
Page2.php
Page3.php
Step 3: Go to the management background to set the corresponding menu, and the foreground will be displayed normally (after the menu is created)
Problem:
An error occurred while creating nav4 on the page4.php page following the above steps:
Fatal error: Call to undefined function wp_nav4_menu () in /...... /Page4.php on line x