Given that you want to include a picture in the wp_nav_menu
output, your best bet is to use the wp_nav_menu_items
filter, as suggested in the comments. This will allow you to do a search and replace on the html.
add_filter ('wp_nav_menu_items','wpse229358_filter_menu');
function wpse229358_filter_menu ($items,$args) {
$search=""; // html string of button
$replace=""; // html string of picture+name
if (yourcondition) {
str_replace ($search,$replace,$items);
}
}
Related Posts:
- Get Current Menu Location inside Nav_Walker
- Remove unwanted elements for a wp_nav_menu
- How to show only the last two categories in a menu?
- add_menu_page() with different name for first submenu item
- How to add sub-menu to a menu generated by wp_nav_menu by using plugin
- Change the_title() of a page dynamically
- How do I programatically insert a new menu item?
- Add Dividers or Separators Between Nav Menu Items
- Nav Menu meta failing to import
- Overwriting Core WordPress Functions with Plugins
- Some nav-menu filters do nothing
- Determine which theme location a wp_get_nav_menu_items is for
- Can I add pages to my custom menu via script?
- Replacing WordPress menu functionality with a plugin
- Hook event for upload image in the menu
- Why isn’t the Settings API designed to work for plugins using custom admin menus? [duplicate]
- How do I approach removing menu items on the fly based on settings in my plugin?
- What is the difference between current_page_parent and current_page_ancestor?
- Delete a specific item menu when I deactivate my plugin
- Create a Page via plugin
- Add Submenu Link in add_submenu_page That Opens in a New Window
- How to assign a WP 3.0 custom nav menu to a theme’s navigation menu location via script?
- Header Button Chance Polylang Elementor
- PHP 7 – Class Method Compatibility Issue
- How to add pages to custom menus on the fly [duplicate]
- How do I add a custom sublevel menu specified in one directory to a custom top level menu specified in another directory?
- Add notification bubble notice in navigation using transients
- Adding custom fields to WordPress nav menus
- Sub Menu content is being duplicated
- Plugin menu addition in multisite
- Is this best practice for Dynamically adding items to WordPress menus?
- How to remove or add submenu item on plugin activate or deactive
- Custom code for WordPress dynamic menu
- How do I access the menus produced by Dashboard > Appearance > Menus
- wordpress add_submenu_page adds broken link
- WP Enqueue style on all plug-in pages
- Add child pages to submenu automatically
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- Issue with plugin sub menu and pages
- How to add Plugin functionality in WordPress Frontend Menus
- How to hide page links from theme menu
- WP_NAV_MENU filter targets all menus
- How do I add a menu item to a Pods admin menu?
- Add user managable titles to custom menus?
- How to create archive page to add in menu
- Always hide a page from the menu
- remove different admin menu for specific users
- How to get an array out of a nav menu if it’s a plugin?
- What happens when you create/edit a menu
- Plugin admin list pages as submenu
- Adding parent custom post type menu option
- Create and style menu
- Change the class of wordpress menu
- Invalid Menu Items
- Declaration of mandoe_menu_walker::start_el(&$output, $item, $depth, $args) must be compatible with Walker::start_el(…)
- Custom Nav Walker $item->url producing malformed hyperlinks
- Displaying an Uploaded Image as a Custom Avatar in WordPress
- Adding a navigation with wp_nav_menu() to a custom block in the site editor
- Adding more options to the instance of an image. (Attachment Display Settings)
- Trouble with Transient API when W3TC is activated [closed]
- WordPress REST API call generates nonce twice on every call
- Adding a class (arrows) to main menu links that have children?
- Filters ‘request’ and ‘parse_query’ not firing in sites.php nor link-manager.php
- How to trap “Publish” button to check for meta box validation?
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- set_sale_price in WooCommerce [closed]
- Adding extra pages to plugin that shouldn’t appear in the sidebar
- jquery document ready function not being called [closed]
- How do I include background images in my stylesheets in a plugin?
- Custom plugin icon not showing up
- $reverse_top_level works the opposite way according to Codex?
- How to export post meta with images in wordpress
- Parse form values before sending to options.php
- My WordPress plugin cannot load my JavaScript file
- Password field is empty when using wp_signon();
- Show error message after exception handled
- WP Cron being triggered but not working as expected
- Plugin Options Array Set to Undefined
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- Plugin Development – Class Constructor Not Firing wp_enqueue_style action hook
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Getting a WordPress Debug Strategy
- Implement a Walker with custom object rather than WordPress database object
- How remove trashed WooCommerce orders from wc_get_orders() result?
- How do I get variables from my plugin’s settings page?
- Adding Additional Variables on Menus Page
- Unexpected T_FUNCTION
- How to avoid conflicts with db.php / $wpdb and other plugins that decide to use them?
- Is there an action_filter hook to add content before the post title?
- Hook or callback when wp_nav_menu() has completed
- Add quick edit functionnality to plugin table
- Hide / show settings field based on other field’s value
- $_SESSION inside php function executed by AJAX
- Two same AJAX calls – one is working, other doesn’t
- add pagination to wp_remote_get
- Shortcode from a plugin not working
- How to get option values without requiring wp-load?
- How to use permalink query to go to specific tabs in posts
- Conditional query tags do not work before the query is run. Before then, they always return false
- Using walker to display all menu branches at once?