First step is to register the name (or names) for your menus. In your example, top-nav seems appropriate.
function vd_register_menu() {
register_nav_menu('top-nav',__( 'Top Nav Menu' ));
}
add_action( 'init', 'vd_register_menu' );
This will allow you to build your menu items in the WP admin under Appearance > Menus.
To display your menu on the site, simply call the wp_nav_menu()
function where you wish to print the code.
<?php wp_nav_menu( array( 'theme_location' => 'top-nav' ) ); ?>
Full documentation available via WP Codex: https://codex.wordpress.org/Navigation_Menus
Related Posts:
- How do I make an HTML table from a database table?
- How to get the custom header image’s alt text?
- Modify previous and next text from pagination links
- Correct regex for wp_embed_register_handler
- WordPress custom taxonomy description for each post?
- Calling a method from functions.php on a click of a button
- Conditional statement for parent, child and grandchild pages
- Two posts in same div – WP loop
- How to add a post or page tag to the list of classes appearing in the body tag’s class attribute?
- WordPress Wysiwyg Content not being displayed
- HTML table from shortcode with multiple parameters
- To echo or not to echo?
- How do I add HTML to a PHP function [closed]
- Correct syntax to html php conversion
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- WordPress automatically adding html tag around PHP code
- Missing sidebar parameter “fix” – before_content
- How Display Posts on category
- ACF page while loop breaks footer while loop
- Getting a specific post values to another div or modal
- Converting HTML Template to WordPress Theme
- search and replace preword from author
- Embed html in php code
- WP grandchild categories in nested ul li
- Customize position of social icons in upme plugin [closed]
- Settings API callback function inserts html quotes from nowhere
- How create a Shortcode with hover and complex options
- WordPress Multiple Navigation bars
- Position banner to right of logo in header – messed up my header file
- How to separate HTML and WordPress files
- Login to wordpress by clicking a link and specifying usernaname and password in url
- Make PHP work with HTML tags
- Syntax error when I try to insert my loop into an unordered list? [closed]
- How to make modifications only to certain elements of an HTML string on the server-side?
- Function returns text instead of html [closed]
- Printing HTML codes
- How i can get post data from database when i am getting post id from url in wordpress
- How to retrieve the data from the sever and displaying it in a page?
- How to execute html code inside php?
- Add data-id attribute to child page links
- wp_insert_post() with HTML tags using PHP
- Prevent redirect to wp-login.php
- Where can I find the inline-css of my theme header?
- Make textarea required. Help [closed]
- How to use the checked() function to check for a non-empty var
- Remove   from the_excerpt
- Find out last 7 days of upload images, last week uploaded image from Gallery and display them in different pages
- Website completely messes up when logging out
- Calling PHP Titles inside Javascript Markup
- How can I use custom menus with a Bootstrap WordPress theme?
- Replacing WordPress Icons (menu,icons32, etc)?
- Custom forms with HTML
- Wrap title and excerpt in a div (latest posts block)
- how to changes mobile menu toggle breakpoint in WordPress
- html form: redirect page after form completes submit function and posts data
- HTML Form Question
- WordPress Post Block Element not properly parsed with the_content filter
- Hide A Class and Add Custom HTML Code Using WordPress
- Add other class content with reference class value
- What are the advantages/disadvantages of ways to use php template files?
- Configure WordPress to Use Responsive Image Rendering
- How to use data URL in WordPress?
- HTML comment cause issue in functions.php script root
- Slug duplicates once clicking on link
- Remove span tags from WooCommerce Downloads page
- How to enable HTML tags in category description without breaking the category page
- How to find and delete a menu item in php?
- My single.php page skips the first div tag
- Custom woocommerce payment gateway – Form
- opens like sitename.com/URL
- WordPress Slider is not working
- How to display post meta bellow every posts
- Make a full-width wordpress page
- Display child-page links in sidebar on both Parent Pages AND Child Pages
- Access certain Entry in HTML-Table and pass the entry-data in WP not working [closed]
- Switch position of elements in the footer [closed]
- Add Text Area To Child Theme’s Home Page
- Can’t get_users info by using json_encode
- scroll scrpit to particular button position to next id when click button
- Code works on page-example.php by not category-example.php
- how to remove replicating a tag inside loop?
- Add Alt attribute to image served with php
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- Add options to WordPress backend
- WordPress HTML Helper
- echo variable containing html and the_permalink();
- Trying to customize wordpress drop down categories
- get_post_meta is always empty when I use wp_mail
- Save Option on Database
- Parse error: syntax error, unexpected ‘echo’ (T_ECHO) in C:\xampp\htdocs\AttendanceSystem\resources\php\method.php on line 250 [closed]
- Implement “No related posts for this entry” into the loop?
- ACF repeater image in video poster with jquery
- Load Meta box value into div AJAX [duplicate]
- Advanced Custom Fields Show PHP in Text Areas
- Parse error: syntax error, unexpected ‘}’ in
- Sorting Problem
- Add multiple HTML attributes to an Elementor button
- Saving meta box data from selected option’s value in database is not working
- Word press – JSPDF – Sending PDF as attachment from wp_mail – Special characters
- How to create different templates for woocommerce single-product.php?