I have integrated html page in wp ,but problem arises when I tried
to display wp menus. I have also created multilevel menus in wp-admin. I have used below method to display menus .
wp_nav_menu( array( 'theme_location' => 'main-menu' ) );
what should i do ,to display multilevel menues in custom pages with their style
you can directly use this plugin
https://wordpress.org/plugins/multi-level-navigation-plugin/screenshots/
Related
I tried googling this, but not having much luck...
I have been able to create a menu using wordpress and entering this code in my header:
<?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>
And this in my scripts part:
function register_custom_menu() {
register_nav_menu('header-menu',__( 'Header Menu' ));
}
add_action( 'init', 'register_custom_menu' );
But it seems that when trying to sort it, using the left side bar in the customize theme mode, it will not sort the menu nor will it remove any part of the menu that I add or remove using it.
From what I can tell it's just pulling my pages that I created within wordpress.
Keep in mind, this is a new theme I'm creating - my first theme. I have no PHP experience. Trying to learn as I go.
Picture of issue
I removed some of the names of the links for public view. I need to figure out how to also style this properly, but I've seen some other posts about it, so I'll review those later.
If someone can help me get this side menu to work with my current menu that would be great!
If you try altering your wp_nav_menu call to the following (no parameters):
<?php wp_nav_menu(); ?>
It should fall back on the first non-empty menu. While you may want additional menus later/will likely want to customize your menu(s) more, this should help with troubleshooting as whatever initial menu you have created (is non-empty) is the menu being edited by the customize page.
From what I can tell it's just pulling my pages that I created within
wordpress.
This likely relates to the setting "Automatically add new top-level pages to this menu" in the menu settings tab. This may be found under Appearance >> Menus, or under Customize >> Menus >> Clicking on the arrow to the right of your primary menu >> menu options (at the bottom of the resulting tab on the left).
Have you tried building the menu through Appearance-->Menu?
In the Wordpress backend, go to "Design > Menus", create a new menu there, add all entries you want to have, give it a name and in the "positions" tab on that page, assign it to the defined position in your theme (header-menu in your case). And disable the option to add all new pages/posts automatically.
I would like to create a second navigation menu that goes below the main one (The one that contains the "About" and "Contact" etc. categories). This one would have images that have links and also which show text under them when hovered on. I have already created the necessary HTML and CSS for it, I just don't know how I would implement that into my site. The images and links are in a table, but the Wordpress navigation menu is a list, so I'm kind of stuck on what to do.
Are you using a default/premium/free theme, or did you create one by yourself?
I assume the first, so here are a few things you need to know.
Wordpress uses hooks, so you can "link" your code at a certain point of their code, when a website is called. In its codex, you can learn more about how navigation menus are registered and called later on.
A theme is something like a base, when you create your own website. You can create child themes and implement every further functionality and design changes
right there.
In short: implement your menu, put it in your child theme and use the hooks to get it where you need.
Standard way of adding a secondary menu to a theme is as follows.
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'yourtheme'),
'secondary' => __( 'Secondary Menu', 'yourtheme' ),
) );
Nevermind, the question I was trying to ask is where do I put my HTML code of the table so that it shows up on the header, but I found the solution through sheer luck. I put the HTML into the header.php of my child theme and linked the CSS classes to those that I pasted into the style.css . Still, thanks to those who tried to answer!
I am currently using Twenty Thirteen theme and I want to create a secondary menus. I am not entirely familiar with the PHP codes. I was wondering if you know how to insert the proper code in function.php? Also, do you know the code to insert in header.php page?
Here is the example of codes from Twenty Eleven theme:
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'yourtheme'),
'secondary' => __( 'Secondary Menu', 'yourtheme' ),
) );
<nav>
<?php
wp_nav_menu( array('container_class' => 'menu-footer',
'theme_location' => 'secondary') ); ?>
</nav>
Thanks!
by secondary menu, i assume you mean a sub menu? this is done in the wordpress cms. first create the pages, then go to the menu module and add them to the primary menu you have already set up. then they will appear with when you call the menu. you will have to stylize them in css to get them to be a nav bar and there are tons of tutorials and already answered questions on that.
if you are creating a second separate menu, then you are on exactly the right track with registering the menus. but then you want to call them with the wp_nav_menu() in different places, unless you want to join the menus, which you can do by placing <ul></ul>around the php code.
always actually create the pages and menu wordpress and once you register it, be sure to go back in to the menu and link the menu to the location under the manage location tab. check codex if you don't know what i mean. you may have forgotten that step. good luck!
I'm currently developing a custom theme for Wordpress which also uses WPML. One of the features is a page independent "Quick navigation menu" that resides in the sidebar of pages.
My approach is to use custom menus (Appearance->Menus) for this. On Edit Page screens I want to include a metabox with a dropdown for selecting the right menu. Creating the metabox is easy:
function page_menus_meta(){
add_meta_box('page_menusid', 'Quick navigation menu', 'page_menus_metabox', 'page', 'normal', 'high');
}
add_action( 'add_meta_boxes', 'page_menus_meta' );
The problem is in displaying the available menus. It must be possible, since the widget "Custom Menu" exists and does exactly that. But when I list all menus I also get the menus translated by WPML which I do not want. I use..
$menus = get_terms('nav_menu');
..for displaying the menus.
My question: How do I list all english-only menus alike the Custom Menu widget?
Subquestion: If someone knows where the code for the Custom Menu resides in the WordPress core I might figure it out myself. Can't seem to find the file though..
I am working on one Wordpress website. We use twentyeleven theme. Site is available in 3 languages, Czech, English and Russian. For translations we use qTranslate plugin for Wordpress qTranslate plugin .
In the beginning we didn't have any problems with translations. But after some time qTranslate stopped translate navigation menu items. We have 3 menus and each of them has specific items. If I don't select main navigation menu in theme properties then translation works, but all menu items from 3 menus are shown in one big menu, which is not good. If I choose one of these 3 menus as main, then translation stop working. The weird thing is that only menu items don't translate, other parts of website (articles, headers, links) are translated properly.
Have you ever had this kind of problem with this plugin ?
My approach to multilanguage menus in wordpress was:
In the header.php theme file:
<?php wp_nav_menu( array(
'theme_location' => 'top_menu',
'menu' => 'Menu ' . substr(get_bloginfo ( 'language' ), 0, 2) ,
'menu_id' => 'mainnav',
'sort_column' => 'menu_order',
)); ?>
Then I've created different menus for each language:
The function I've used get_bloginfo returns the locale in the qTranslate section:
It worked for me. Add suggestions or other plugins to turn this into an easy task.
I had the same problem.
In WordPress Dashboard check in Appearance -> Menu under Menu Structure.
Click the arrow on the right of the item to reveal additional configuration options and check if Navigation Label names are different when you change languages with q-translate if not add your own translations.
Hope that helps.