Tag Info

New answers tagged

0

This is how I added data attribute to my menu It simply adds data-title="menu-title" to each link on my main nav, change it to adapt to your need. You don't actually need to use Nav Walker to add this add_filter( 'nav_menu_link_attributes', 'cfw_add_data_atts_to_nav', 10, 4 ); function cfw_add_data_atts_to_nav( $atts, $item, $args ) { ...


1

Here's how I solved it so far. class themename_walker_nav_menu extends Walker_Nav_Menu { function start_el( &$output, $item, $depth, $args ) { $slug = get_post( $item->object_id )->post_name; $item->url = "#{$slug}"; return parent::start_el( $output, $item, $depth, $args ); } }


0

It turns out i solved the problem by renaming my Staff template from archive-staff.php to page-staff.php (or anything else for that matter), thus specifically telling Wordpress not to trust the template hierarchy logic and to consider that url as a "page" url, not a custom post type archive. If you happen to have a use for this function, be aware that it ...


1

That's a nice option, but I agree with sri, right now it really depends on your theme. You can do a work-around through is_page(). You need to write something like this on your page.php theme file: <?php if (is_page('projects')) { if ( is_active_sidebar( 'sidebar-navigation' )) { dynamic_sidebar( 'sidebar-navigation' ); } ...


0

You can modify your menu by using walker. include('subMenu.php'); $menu = wp_nav_menu( array('menu' => 'YOUR-MENU-NAME','menu_class' => 'megamenu','walker' => new subMenu)); create a file subMenu.php in theme folder add below code. <?php class subMenu extends Walker_Nav_Menu { function end_el(&$output, $item, $depth=0, $args=array()) ...


0

As suggested by Nilamber, You will have to check the parameters defined in $args. The following code will work but you can modify it as your ease. add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 ); function add_loginout_link( $items, $args ) { if (is_user_logged_in() && $args->theme_location == 'primary') { $items .= ...


0

As Nilamber Suggessts: /** * Add Login/Logout to Menu */ function add_login_logout_link($items, $args) { if( $args->theme_location == 'primary' ) { $loginoutlink = wp_loginout('index.php', false); $items .= '<li>'. $loginoutlink .'</li>'; } return $items; } add_filter('wp_nav_menu_items', ...


0

Change the filter hook to wp_nav_menu_{menu-name}_items, so it will only run on a specific menu. For example, if the menu name is "Secondary", use the hook wp_nav_menu_secondary_items, or if the menu name is "Top Navigation", use wp_nav_menu_top-navigation_items (replace spaces in the menu name with dashes). Your updated code, assuming the menu name is ...


1

You can modify your menu by using walker. include('subMenu.php'); $menu = wp_nav_menu( array('menu' => 'YOUR-MENU-NAME','menu_class' => 'megamenu','walker' => new subMenu)); create a file subMenu.php in theme folder add below code. <?php class subMenu extends Walker_Nav_Menu { function end_el(&$output, $item, $depth=0, $args=array()) ...


0

I've resolved the problem with explained here : http://marketermatt.com/export-navigation-menus/ But i would like to warn the people that will try this solution, you have to have a database backup of WordPress system which has Menu that you would like to revert BackUp your WP database to your PC (bacause, you will use this for reverting back your system ...


0

Another option would be to take a look at what the $item variable includes within thestart_el() function. For example, the menu-order property might be of use to you. function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { echo $item->menu_order; } This might output something like: 1234 if you have four menu items.


0

I ended up removing that code from my functions.php file and used jQuery instead. Here's how I took care of it, if anyone wants to know: $('.menu-item-has-children > a').each(function(){ var submenuHeading = $(this).text(); $('.sub-menu', ($(this).parent('.menu-item-has-children'))).prepend('<h3>' + submenuHeading + ...


0

I have done a complete answer on this a while ago on SO. You can see the complete post here. For the sake of WPSE users, I have copied my answer from that post. I have not edited it, this post was originally about adding and displaying a nav menu to the footer, but the same exact method applies for a header nav menu. I hope you find this helpful ORIGINAL ...


0

array_intersect() is not a good choice when you need a partial match. Go through each class, and apply both checks before you remove a class. Example, not tested: function remove_menu_classes( $classes ) { // List of allowed menu classes $allowed = array ( 'current-menu-item', 'current-menu-ancestor', ...


0

WordPress navigation menus won't conform to styling or coding changes if they are being built by default. You have to actually go in and create the menu in Appearance > Menus and assign it to the menu location. After you do that, it should conform to coding/styling standards you set, as opposed to system defaults.


0

I heard about this issue. Just try to disable jetpack mobile theme in your settings. Shut works. Best Regards


0

Ended up doing via jquery jQuery('.menu-item-has-children').each(function(){ idLi=jQuery(this).attr('id'); jQuery('#'+idLi+' ul').wrapAll('<div class="slideFromtop">') });


1

Without getting your hands too dirty, a lot of themes come with a CSS editor built-in so you overwrite rules. Feel free to do this for simple changes, and just be wary that your changes could get overwritten if you decide to update your theme in the future. However, if you feel comfortable going deeper, you can FTP your own CSS file with changes. This is a ...


0

This link helps me to solve my problem. : http://wordpress.org/support/topic/how-to-show-the-description-of-the-menu


1

Try this - I've not implemented it fully, but I have tested it and it seems to work. Place it in your functions.php and call <?php list_child_pages(); ?> in your template or use the shortcode [childpages] in your editor. <?php // List Child pages of a parent. function list_child_pages() { global $post; if ( is_page() && ...


0

Here's my solution : First, make all of your pages you want to move to be a subitem of some other item(the best way is creating one for this action bacuse you will delete parent item). Remeber that when you move your items you must move it with parent item like above. Then put items in place you choosen and delete parent item . Here - "Stowarzyszenie" ...


0

I think there is a 'more reliable' option. Relying on the menu item number is not garanteed to work if you migrate your code from development to production for example. If you turn the number into a setting it is getting better, but still not really good. An alternative could be to link to a non-existent anchor, like #olark, from your menu-item. This can be ...


0

Did you actually create a specific menu and link it to one position you defined in functions.php? Once you do not link it to a position, WordPress grabs all pages and puts it in a menu. You should go like this: 1.) You put something this in the functions.php of your theme in order to register menues (if you only need one, leave out the line with the ...


1

Particularly since you're putting the categories into an unordered list, it seems worth mentioning that wp_list_categories() gives a class to the current category by default on archive pages, comes with a $current_category argument for special use cases, and is really just a complicated wrapper function of get_categories(). I don't know the exact context of ...


0

If you mean in the footer? I looked at the Blaskan Theme, and saw hyphens in the footer menu. To change that... use CSS. Make the #footer-nav li:before { content: " \007C "; font-family: Arial, sans-serif; } That will change it from a hyphen. To a | To make it space out better, you may want to add padding-right: .4em;


0

Sorry this is not the direct answer but as a bit of help, you can read this article that Chris Coyier kindly wrote few years ago on this painful topic http://digwp.com/2011/11/html-formatting-custom-menus/ But it looks like there is no easy ways for your idea :) I guess you would want to use in these sub_labels page's meta titles? Have you tried to use ...


0

<?php if (!function_exists('debug_admin_menus')): function debug_admin_menus() { global $submenu, $menu, $pagenow; if ( current_user_can('manage_options') ) { // ONLY DO THIS FOR ADMIN if( $pagenow == 'index.php' ) { // PRINTS ON DASHBOARD echo '<pre>'; print_r( $menu ); echo '</pre>'; // TOP LEVEL MENUS ...


0

The problem is in your sub-labels below the main text in each item. When building menu, set a custom name to menu item with like this: World News From Around The Globe Another method is to use a megamenu WordPress plugin, which supports two labels.


0

EDIT: Sorry, didn't noticed the date of the question before answering. function add_favorites_link( $items, $args ) { // Check is user logged in if ( is_user_logged_in() ) { $user = wp_get_current_user(); $ID = $user->ID; $fav = '<a href="'.bbp_get_favorites_permalink( $ID ).'">Favorites</a>'; // ...


0

I found the problem: I used a 'link' menu item instead of a 'page' menu item because it was originally a post type archive (but I changed that in a page). If I use a 'page' menu item the current-menu-item CSS class does work when there is an url parameter in the url.


1

Just use CSS to style your #nav li block. This is quick, but would make your links into buttons. #nav li { list-style: none; background: #F00; width: 120px; margin-right: 60px; padding: 10px; text-align: center; } you can add a hover class too like #nav li:hover


1

What you want can be done. It's just not likely to be really clean and neat. You can accomplish this by using a custom Walker Class for the wp_nav_menu() when you insert it. class My_Walker_Class extends Walker_Nav_Menu { function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $output .= sprintf( "\n<li><a ...


0

Alas, this is a CSS issue, caused by some difference in WP's classes applied. :) First you are misinterpreting your "test" case 2: Dropdown isn't highlighted because (despite what post body says) it's not actually assigned the subcategory. The styling applied is from .current-menu-parent, since post is obviously not a term in taxonomy. In your first ...



Top 50 recent answers are included