Tag Info

New answers tagged

1

Presonally, I would use some CSS workaround. In menu administration you can add CSS class to menu item (if the field is not displayed, you can find it in Screen Options), for example "profile-link". And than you can add something like this to your template HEAD section: <?php $avatar = get_avatar_url( get_current_user_id(), array('size' => 64) ); // ...


1

I believe the filter you want is wp_get_nav_menus: function wp_get_nav_menus( $args = array() ) { $defaults = array( 'hide_empty' => false, 'orderby' => 'name' ); $args = wp_parse_args( $args, $defaults ); /** * Filter the navigation menu objects being returned. * * @since 3.0.0 * * @see get_terms() * * ...


1

Found the answer. It might not be the best way to do it but it is working for now. I was looking on using a filter when the solution seems to be using a custom walker. class edited_menu_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", ...


0

One way you can achieve this is by: Using a JavaScript library such as SlickNav which allows you to create a responsive mobile menu, with burger icon, based on existing menu markup. (recommended) Also there is Responsive Nav (resize browser to see demo) And this tutorial Simple Hamburger Drop-down Menu with CSS and jQuery that you can use inconjunction ...


1

Add to your functions file and use wp_nav_menu_items add_filter('wp_nav_menu_items','wpsites_add_avatar_to_nav', 10, 2); function wpsites_add_avatar_to_nav( $items, $args ) { if( $args->theme_location == 'primary' ) return $items; $dude = get_avatar( get_current_user_id(), 48 ); if (is_user_logged_in()) : echo'<li ...


1

You can try this out : <?php global $my_profile; ?> <?php if (is_user_logged_in()){ $avatar = '<div class="img" data-key="profile">'.get_avatar( get_current_user_id(), 64 ).'</div>'; }else{ $avatar = ''; } ?> And your menu code should be like this $defaults = array( 'theme_location' => 'location of menu in ...


0

If you want your navigation span element to be a block, instead of inline element, just target it via css nav > ul > li > a > span{ display:block; } This is providing your HTML structure looks something like this: <nav> <ul> <li> <a href="#" class="menu-link"> ...


0

First thing get_current_theme() is deprecated since version 3.4 you need to use wp get theme() to get the current theme name. And about add_menu() you can only use it at action hook admin_bar_menu as codex say about it: This is not a function. It is a method of the $wp_admin_bar global (an instance of WP_Admin_Bar), which may not exist except during the ...


0

You can find Menus in the Appearance->Menus area in the admin. Are you using a custom theme? If so, it might have menu support. Try switching to one of the default themes. If it still, doesn't appear, disable all plugins and try again.


0

Here's one way to do it with the help of the menu CSS classes: For the menu item that you want to modify the label of, add the wpse_menu class to it: This is supported with: /** * Modify the title of menu items that contain the 'wpse_menu' class. * We restrict this to the primary menu. */ add_filter( 'wp_nav_menu_objects', function( $items, ...


0

Expanding on @Eugene's answer, if you want to limit this to a specific menu, just check the term ID of the menu: function custom_nav_args($args){ $menu = $args['menu']; if($menu->term_id = 17) /* replace term_id with menu id, or use $menu->name to do it by menu name*/ { $args['walker'] = new My_Custom_Walker(); } return $args; ...


1

It's a simple solution of Setting the menu position to Secondary navigation, AND Handheld Setting an empty menu for for position Primary navigation. In my screenshot I haven't removed the primary navigation though.


0

Skimming through the core file, there are some quick & dirty ways available (untested): ! is_admin() && add_filter( 'wp_nav_menu_items', 'do_shortcode' ); ! is_admin() && add_filter( 'the_title', 'do_shortcode' ); ! is_admin() && add_filter( 'walker_nav_menu_start_el', 'do_shortcode' ); But I would rather ...


0

This is a good way, Mardov. Another way is to specify the subcategory id in the in_category array which is easier method. For example: if (in_category( array( 2, 4, 5 ) ) { // 2, 4 & 5 can be a category or a subcategory wp_nav_menu( array( 'menu_class' => 'menu','menu' => 'Visuomenei') ); } You may find it difficult to find the IDs of the ...


0

You want get_field() (which returns the value), not the_field() (which echo's the value): $var = get_field( 'menu2' );


0

Tried with this and got the solution add_submenu_page( 'page_main', "Articles", "Articles" , 'adminstrator', 'edit.php?post_type=page_article' ); Thanks


-1

Have you updated the links in your database? Are they still pointing to your live site? Sorry, I will elaborate. If you download your database you will see that the url for your live site will appear several times. For example: INSERT INTO `wpfr_options` (`option_id`, `option_name`, `option_value`, `autoload`) VALUES (1, 'siteurl', ...


1

There are several ways to answer that question, depending on what it is you are attempting to accomplish. To generalize, you need to create two queries: one to get all public posts and one to get all public taxonomies and terms. Getting both in one array is not practical as term objects and post objects have different formats - however you can construct your ...


1

I would avoid any core-related layout classes and just roll your own (you don't need bootstrap for this). In your PHP page handler, just kick out something like: <div class="wrap"> <div class="my-plugin-column"> How... </div> <div class="my-plugin-column"> you... </div> <div ...


0

The menu that is reversed is because it is float:right;. That's the expected behavior when you use float:right;. This has nothing to do with WordPress itself it is a purely CSS issue.


1

For outputting only li's add this to wp_nav_menu array: 'container' => '', 'items_wrap' => '%3$s',


1

I think this is a bad case of taxonomy split introduced in WP 4.2 ref. https://make.wordpress.org/core/2015/02/16/taxonomy-term-splitting-in-4-2-a-developer-guide/ Solution for this would be to use this plugin to detect and fix the splitting before Updating menus which is a bit buggy in my opinion. Update nav menus will trigger ...


0

This is what I'm looking for and it works well for the direct category of the post, but I can't figure how to add a current-parent-category to the parent level. Any idea?


0

As others here have suggested you can create a custom link menu item with the # as its url. Then erase the # once it is added to the menu. And finally, you can use this simple regex to strip the actual tag from those links. preg_replace('/<a>([^<]+)<\/a>/i', '<span class="no-link">$1</span>', $navHTML);


0

I have found other alternatives to do that in the top of the walker i create a variable private megamenu_state; than in my walker if($depth == 0){ $this->megamenu_state = $item->megamenu; } so the variable will get the state of the top level.


0

In a nutshell, assuming you are using a walker to construct your menu. E.g. when customizing the start_el() method, the $item should be an object - somewhat - like the $post object. In reverse that means, you have access to post_parent property. With that information you can retrieve the title with get_the_title() easily. After your edit I see you want ...


-1

If I understood your question correctly: set your permalink structure as /%category%/%post%/ and from your mega menu create custom links for taxonomies categories and single posts.


0

What i have understand that you want to change the class of all li element to be what you want try this class myWalker extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = array()) { $output .= "\n".'<li class="your_custom_class" id ="your_custom_id>'."\n"; } function end_lvl(&$output, $depth = 0, ...


2

Whenever you add a new item to WordPress Menu ( Appearance -> Menu ) it creates a new Post of Post Type nav_menu_item and gets assigned a post meta called _menu_item_object_id with the main Post ID. For example, if I create a page called "Home" it gets assigned a Post ID of 2. Now, when I go to Menus and add the page to a menu, WordPress creates a new ...


0

I think you should probably use wp_list_categories(), which even has parameters for a count, like e.g. show_count and pad_counts. Additionally it supports custom walkers via the walker parameter, but the walker would be based on Walker_Category - source -, which gives you every additional styling option you want.


0

I had a similar problem and here is the best solution I could come up with. The reason (I think) that private or non-published items show up in menus is that the menu items are themselves posts and have their own post_status. That means that in a situation where a page is marked private, the menu item for that page can still be set to publish, and is ...


0

If you check out has_nav_menu(), you'll see that it first checks if a menu exists for the location (what we expect). However, it will also return true if the location is merely registered, hence why your condition is still true even when there's no menu: function has_nav_menu( $location ) { $registered_nav_menus = get_registered_nav_menus(); if ( ! ...



Top 50 recent answers are included