In your theme’s functions.php
, write the following code:
<?php
/* ENABLING CUSTOM MENUS
-------------------------------------------------- */
//add_theme_support( 'menus' );
register_nav_menus(
array(
'primary'=>__('Primary Menu'),
'secondary'=>__('Secondary Menu'),
)
);
?>
It’ll register two custom menu area for your theme.
Then you need to achieve it with in header.php
:
<?php wp_nav_menu ( array ( 'theme_location'=>'primary', 'fallback_cb'=>'') ); ?>
This code will place only the Primary Menu area in your theme.
Now you need to code the CSS, and These whole bunch of code is really amazing! I found it from a tutorial site.
Try it and then modify it as per your need, and then find the author of the code (not me) and thanks him. 🙂
Related Posts:
- WordPress security issue to output data from user input from theme option form
- Get Current Menu Location inside Nav_Walker
- How to create a backend for a custom theme?
- Add child pages to submenu automatically
- Create fixed static pages
- Override category archive page title (not the head title)
- How to hide/remvoe unnecessary field/section in post edit section ( Dashboard )
- Post Pagination does not working on WP-Query
- Managing Custom Designed Content
- Invalid Menu Items
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- What process do you use for WordPress development? [closed]
- What is the advantage of using wp_mail?
- Should Plugin Folders Include a Blank index.php File?
- Add Dividers or Separators Between Nav Menu Items
- Overide get_template_part( ‘partials/post’, ‘sidebar’ ); with a plugin
- Should I create a theme or a plugin?
- Where do I start from
- WP 3.3 Tooltips API?
- wp_remote_get doesn’t work with secure connections https?
- Using a Theme inside a Plugin directory
- Authoritative answer on which boots first – Plugins or Themes?
- How to Add Font Awesome Icons to WordPress Menus?
- Overwriting Core WordPress Functions with Plugins
- How to Use WordPress Color Picker API in Custom Post Type Metabox
- Custom theme sufficient or custom plugin neccessary for this feature set?
- Can I add pages to my custom menu via script?
- How to create custom home page via plugin?
- Replacing WordPress menu functionality with a plugin
- How to debug WordPress correctly?
- Programmatically Selecting Theme Based on URL
- Featured Image not showing in admin
- How do I approach removing menu items on the fly based on settings in my plugin?
- Whats the difference between blog_info(‘stylesheet_url’) difference get_stylesheet_uri()
- Paging on a future post loop?
- Add Submenu Link in add_submenu_page That Opens in a New Window
- Where is definied the theme location for the main menu in a WordPress template?
- How to check if a stylesheet is already loaded?
- Problem with is_active_sidebar?
- Change template dynamically
- WordPress add_admin_page not working even parameters are correct?
- My Admin bar covers my sticky navbar [closed]
- Howto: Use Custom Post Types as Submenu Items in Admin
- Plugin menu addition in multisite
- Extending theme PHP class in plugin
- How to limit number of number of categories displayed by categories widget
- How to hide or rename “X” and “x-child” references in website source?
- Redirect to another page using contact form 7? [closed]
- Plugin is not generating title tags on any pages or posts
- Is it necessary to do validation again when retrieving data from database?
- Update Data parameter of a wp_localize_script() call
- 3 Level Deep Navigation Menu Not Showing All Levels
- get_the_tags with separator control?
- Customize existing menu item
- Why in this archive page that call query_posts() function show only the last 10 posts?
- How to add menĂą section to my WordPress template?
- PHP File_exist() not working – Checking if File Exist in WordPress Theme Directory
- Why would you use esc_attr() on internal functions?
- How to find where an object first instantiatiation
- Full documentation about $args for register_rest_route?
- How to get terms for taxonomy
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- Why in this WordPress theme I can’t see the Main Menu?
- How to remove/replace current page template?
- WordPress dynamic widget by location?
- How do you create a re-useable HTML fragment in wordpress
- How do I add a menu item to a Pods admin menu?
- Adjust query on single
- Using password protection to load different page elements?
- Add user managable titles to custom menus?
- Displaying custom content from a plugin within the active theme
- WP_Query order posts by category
- Getting Post ID at “stylesheet” and “template” hooks
- WordPress Favicon not Working For Images/Videos/PDFs
- How can we stop showing short code in create or edit post section
- Is it possible to develop themes and plugins locally while still allowing content to be updated directly in the admin dashboard?
- Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
- How can I measure CPU and RAM used by my theme or plugin
- set a custom post type to a taxonomy term programmatically in metabox
- Custom premium registration form and profile page for a WordPress Web Application
- My enqueue admin style function doesn’t work because of ?=ver
- How to destroy or dispose wordpress uploder/manager?
- How to get an array out of a nav menu if it’s a plugin?
- Why the output of an image gallery plugin is not displayed into a page of my custom theme?
- To remove rendering of menus and header, plugin or theme?
- To remove rendering of menus and header, plugin or theme?
- How can I add recent posts to menu like mashable
- Primary Menu Showing All Pages With No Sub-Nav
- Display Data’s metabox in page
- Plugin admin list pages as submenu
- Ajax functions – no access to wp-admin.php only online
- Breadcrumb is not generating the correct post page url
- Developing Themes on WordPress, Looking for Excellent Tutorials [closed]
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- Loading jQuery library from WordPress admin
- Using tag or inline style attribute?
- how to insert content into wp_head after loop_end
- How react js and other Javascript Technologies works on WordPress plugin?
- How to automatically set a Template Page Name next to a page in menu screen such as WooCommerce pages, front page, or posts page in wordpress?
- Remove Gutenberg Buttons Block