Tag Info

New answers tagged

1

You are not providing the correct parameter to wp_get_nav_menu_object() function. It needs the menu ID or menu slug but you are providing the menu theme location. Obviously, I can not tell you what is the ID or slug of your menu. One way of getting the menu ID of the menu assigned to theme location is using get_nav_menu_locations(): $menu = ...


0

Your nav menu bar responcive while can user bootstrap framework. This like code insert in function.php Bootstrap responcive nav menu wordpress // This code insert in header.php <div class="container"> <nav class="navbar navbar-default" role="navigation"> <div class="navbar-header"> <button type="button" ...


0

You can take the following steps Go to You Dashboard Click Appearance > Menus Under Pages, Click View All There will be a 'Home' option Check that Home Option Click 'Add to Menu' The new Menu item will appear in the right block Drag the home menu to the top Save the menu


0

I get it that the menu is generated via queries, hence the bottlenecks. If things don't change too often, it's much more efficient to build it manually (or simply just copy the generated html and paste it back instead of source). If things do change often, cache it.


0

As ever, when you know the answer it's maddeningly simple. The custom post types were there all along, together with their taxonomy. All posts are absent from the menu editor and have to be turned on in Screen Options. I pressed the button and lo, there they were.


0

I'm don't know a way of re-using the page picker but you could achieve what you're trying to do with the "Post Object" field type in the Advanced Custom Fields plugin. The post object field creates a select field where the choices are your pages + posts + custom post types. This field is useful for advanced linking to another page / post. ...


0

I figured it out, after trying a million things I tried one more, super stupid but it worked, I just went to permalink settings, clicked save changes and my posts and pages are working again... I don't understand why but finally it's working again.


0

Please check with other themes also. If it is a problem with the current active theme, rectify it at the theme level. First activate a default theme provided by WordPress. If it is working fine, then the issue is with your theme.


0

You need to add overflow: hidden; to your CSS for #wpadminbar. Add this to your CSS: #wpadminbar { overflow: hidden; }


1

Add this to functions.php, or put the CSS into a css file which is loaded in the admin screen. This will let the box become resizable, so you can make it taller and see more pages/checkboxes at once. function wp191833_resize_menu_list() { ?> <style type="text/css"> #wpwrap .categorydiv div.tabs-panel, #wpwrap .customlinkdiv ...


0

Well, after some more intense research I finally found a viable solution that is clean and simple and works flawless so far. Just put this into your functions.php to create a custom walker which turns classic permalinks into hashes (e.g. page.com/mypage to page.com/#mypage): /* Custom nav walker */ class Single_Page_Walker extends Walker_Nav_Menu{ ...


0

I'm currently doing this on a project. First, I use the slug to create the anchor on the onepage-template: <article id="post-<?= get_slug(get_the_ID()); ?>" class="container"> Then. I use the following code in a custom menu walker class to replace the url in the href attribute of the menu item. /** * Figure out if the current item is on the ...


0

The solution I've wanted looks like this: <?php // Allow HTML descriptions in WordPress Menu remove_filter( 'nav_menu_description', 'strip_tags' ); function my_plugin_wp_setup_nav_menu_item( $menu_item ) { if ( isset( $menu_item->post_type ) && 'nav_menu_item' == $menu_item->post_type) { $menu_item->description = ...


-2

add_filter( 'wp_nav_menu_items', 'add_sidebar_output_to_menu998722', 10, 2 ); function add_sidebar_output_to_menu998722( $items, $args ) { if ($args->theme_location == 'nav-location') { $items .= dynamic_sidebar($sidebar['id']); } }


0

It's simple just you need add items_wrap parameter: wp_nav_menu( array( 'theme_location' => 'top-menu', 'container' => false, 'menu_class'=> 'mainmenu pull-left', 'items_wrap' => '<ul class="nav">%3$s</ul>', ));


0

You already did it the right way. If you take a look in the Documentation for wp_nav_menu, you'll see that menu_class is the right option for the UL's class: wp_nav_menu( array( 'theme_location' => 'top-menu', 'container' => '', 'menu_class'=> 'mainmenu pull-left *add-your-class-here*' ) );


1

this can be done with the "add_menu_page" function you can see example of use on this page : http://codex.wordpress.org/Function_Reference/add_menu_page


0

The above works now. Being a greenhorn I just put the code in an empty header.php in my child theme, instead of copying the complete file from my parent theme and then edit it. Nevertheless this is a little effort to archive a different behaviour of the menu on mobile, which is still language friendly, as per Polylang. Happy coding.


0

Most Websites that uses Multi Lingual WordPress uses WPML plugin. It has a build in Menu Sync feature that will add different version/translation of menu for each language. Its pretty much the standard to go nowadays in terms of WordPress sites having more than one language. Check this link for more info: ...


0

Apparently it was a menu registration issue. That menu was readable by WordPress, but not completely, because there were no positions available. I registered again the menu into my functions.php file and it worked. Thank you all anyway.


0

I'm trying to make my logic like this: calling below code inside function start_el( &$output, $item, $depth, $args ) { $this->sub_items = 0; // declared variable as private $sub_items = 0 above inside class if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $args->theme_location ] ) ) { ...


0

In your array, have you tried setting depth to 0 or 2? wp_nav_menu( array( 'theme_location' => 'header-menu', 'container_class' => 'navigator', 'depth' => 2) ) Where 0 should be the default and allow unlimited submenu, and 2 would allow one submenu. I am not sure how this would happen, but if it works, perhaps ...


1

You need to extend Walker_Nav_Menu in such a way that it only outputs, if I understand you, items that are not "zero" depth-- top level. class my_extended_walker extends Walker_Nav_Menu { function start_lvl(&$output, $depth, $args ) { if (0 !== $depth) { parent::start_lvl($output, $depth, $args); } } function end_lvl(&$output, ...


0

Thanks to mstoic for pointing out that this is not default WP functionality. This ended up being an unhelpful feature (for me) used in a WordPress stack. I found the offending line and commented it out. $output .= "\n<ul class=\"dropdown\">\n"; } function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { $item_html = ...


1

Can you add the complete output code for the navigation menu. The code you pasted seems to be a stripped version. Moreover, WordPress adds 'current_page_item' class to the list item if it is currently being viewed. For more info, check this WordPress documentation on classes added to Navigation menu items.


0

might it can help you for your query : Basically I need a way to display widgets in menu, without using any extra plugins. place the code in your theme’s functions.php <?php register_sidebar( array( 'name' => 'Page Menu', 'id' => 'page-menu', 'before_widget' => '<div id="page-nav">', 'after_widget' => ...


0

Maybe you can use wp_get_nav_menu_items() to get the items and then check if an item has a parent. <?php $items = wp_get_nav_menu_items( 'header' ); if( $items ) { echo '<ul id="menu-main-top-navigation">'; foreach( $items as $index => $item ) { if( $item->menu_item_parent != 0 ) echo '<li class="menu"><a ...


0

Here are three approaches: I - Plugin for the a-class- prefix: We can target the <a> tags with the a-class-... class prefix. So in your case the way to get: <li id="menu-item-290" class="blue yellow ..."> <a class="red pink" href="http://localhost/en-wptuts/">home</a> </li> is to use the following menu classes: blue ...


1

As recommended in a similar post: http://wordpress.stackexchange.com/a/156494/74343 1.) Create the menus as you want them, and name them as you like, as an example "mobile-menu" and "desktop-menu". 2.) In your child theme in the header.php you could switch according to the wp_is_mobile() flag like this: if ( wp_is_mobile() ) { wp_nav_menu( array( ...



Top 50 recent answers are included