I am learning Plugin Development. My sub menu code is like below. add_submenu_page('weather_info', 'Weather Information', 'Weathers', 'manage_options', 'edit.php?post_type=weather'); But my menu is not kept open after click. Below screenshot is after click on Weathers.
If I need to edit a specific post then I need to click the "All Posts" link and then find it. It would be nice to click directly on a link from within the popup hover sub menu. Something like this: Disclaimer: I am going to answer my own question.
I've been researching this and had no luck so far. I have a WooCommerce store with a main menu showing product categories (product_cat) and brands (yith_product_brand) which is a custom taxonomy. I want to hide categories and brands if they are empty. Do you know a way to achieve this, either by using a plugin or adding a function/filter to the functions.php file? If so any help would be much appreciated. Thanks in advance.
I Use a custom walker from my menu in WordPress and my menu doesn't show all levels. https://soulofcroatia.com/ ->One Day menu item. This is my code in header.php <?php wp_nav_menu( array( 'theme_location' => 'mainmenu', 'menu' => 'mainmenu', 'container' => 'ul', 'container_class' => 'collapse navbar-collapse', 'container_id' => 'navbarCollapse', 'menu_class' => 'nav-list', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'items_wrap' => '<ul class="%2$s">%3$s</ul>', 'depth' => 3, 'walker' => new Primary_navigation_walker(), ) ); ?> this is my code in custom-walkers.php class Primary_navigation_walker extends Walker_Nav_Menu …
I am creating a custom nav walker but having trouble outputting parent menu item title in start_lvl function. I want to output it right after the <div class="dropdown"> in the following start_lvl function. function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat("\t", $depth); if ($depth == 0) { $out_div = ' <div class="dropdown-wrapper"><div class="dropdown">This is where I want to output parent item title'; } else { $out_div = ''; } // build html $output.= "\n" . $indent …
I need to add product categories to Wordpress menu, but when I'm doing this with WP interface it lose the hierarchy I tried with WP-CLI, but there is no method to specify wich item is the child. There is a method to do it? There is a ton of categories (3-4 level deep), I cannot do this manually I can buy also a plugin. Can you suggest something? Thanks a lot
I want to display the menu & submenu items from Wordpress in another web-application, menu and Submenu are get but there is more menu inside Submenu I want that. function return_menus( $data ) { $menuID = $data['id']; //$primaryNav = wp_get_nav_menu_items($menuID); $x = wp_get_nav_menu_items($menuID); // echo '<pre>'; // print_r($x); // echo '</pre>'; $menu = array(); $submenu = array(); foreach($x as $y){ $y-> submenu = array(); if($y->menu_item_parent === '0') array_push($menu, $y); else array_push($submenu, $y); } for($i=0; $i < count($submenu); $i++) { $index …
I'm trying to edit my CSS to always show all the li tags inside my header menu, also with ul.sub-menu li; I just want to show all the items from the menu, but I'm working on it for hours and I've still haven't found any solution. This is my menu's structure: <ul class="menu"> <li>Item</li> <li> Item 2 <ul class="sub-menu"> <li>Subitem</li> <li>Subitem 2</li> </ul> </li> <li>Item 3</li> <li>Item 4</li> </ul> This is what I've tried so far: ul.menu li ul.sub-menu { …
My website is wiki-style and has a lot of pages that should only be reached through links on other pages. Having these all accessible from the top menu bar under their respective headings leads you from dropbox to dropbox as each page has more subpages- a huge inconvenience. I've managed to hide these in computer view by creating a 'dummy menu'. I added a '-' to either side of my menu bar so it looks like part of the design, …
I have a class like below. namespace Inc\Admin; class Admin { public function __construct() { add_action('admin_menu', [$this, 'admin_menu']); } public function admin_menu() { add_submenu_page('sports_info', 'Sports Information', 'Sports Information', 'manage_options', [$this,'sports_info_page'], [$this, 'html_page']); } public function html_page() { //some code } public function sports_info_page() { //some code } } I am getting below errors. Fatal error: Uncaught Error: Object of class Inc\Admin\Admin could not be converted to string Error comes from [$this,'sports_info_page'] of add_submenu_page().
I have added to my-plugin submenu a custom view of the user list using users.php and a my_plugin_view argument to filter the request: add_submenu_page( "my-plugin", 'Subscribers', 'Subscribers', 'edit_users', 'users.php?my_plugin_view=subscribers' ); When /users.php?my_plugin_view=subscribers is open the admin sidebar toggle Users > All Users instead of My Plugin > Subscribers I have tried: if( isset($_GET['my_plugin_view']) ){ remove_submenu_page( 'users.php' ); } but this removes the All Users section from the sidebar and doesn't toggle the plugin menu as expected. How to keep the …
You see I have a Navigation bar items, in the parent item Products & Services with two sub menus. I have a requirement, when I click the menu item Products & Services it redirect to its sub-menu Dedicated Servers. How can I do with this? EDIT-01 I only want the Products & Services parent have this redirect, the other parent do not need, such as Home, Advantage they all have their own page.
my website is using MyHome theme. I need to write identical names for two search fields. Here - https://komand.suvenirite.net/dava-pod-naem/?offer-type=rent And here- https://komand.suvenirite.net/prodava-offer-typesalecitygrad-sofia/?offer-type=sale Under the search field "ВИД НА ИМОТА" (the first one) The need for that is that the system gets confused if there are identical names even thought their parent fields are different, but for the client they need to appear the same. Yes, I have tried changing the structure, but of no use. The client is unbeatable. Adding …
I researched in google, yandex but had no success. With this code I can set a div to sub-menu but this code add to all sub-menus, I just need to add div to specific sub-menu. class Megratron_div extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); $output .= "\n$indent<div id='megatron'><ul class='sub-menu'>\n"; } function end_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); $output .= "$indent</ul></div>\n"; } …
I am trying to add onclick="toggle_visibility('sub-menu');" into the opening tag of specific menu items generated in WordPress. I have used the following function to target all parent menu items and now need to find the correct js to add this in dynamically. function menu_set_dropdown( $sorted_menu_items, $args ) { $last_top = 0; foreach ( $sorted_menu_items as $key => $obj ) { // it is a top lv item? if ( 0 == $obj->menu_item_parent ) { // set the key of the …
I am building a menu for a client that grabs custom field data from the top level menu item's pages and adds data-color to that menu item. I have that part working no problem. The issue I'm having is applying that data-color from the top level item to the child menu items. Since the child menu items aren't necessarily child posts/pages of the top level pages I can't use $item->post_parent. I'm a little stuck at this point on my next …
Been searching for any related plugins or info. about this case but didn't find anything relevant or working. I need every new tag that is added to a post automatically appear in a menu as a sub-menu item. Something like you can make pages automatically appear in a menu. Thank you very much!
Can anyone give me a clue how this menu system was created? https://40thdems.org/ This is a WordPress site using the Divi theme. Thanks in advance for any pointers!
I've created this page: function wpdocs_register_my_setting() { add_submenu_page( 'edit.php?post_type=task', 'View Tasks', 'View Tasks', 'manage_options', 'view-tasks', 'view_tasks_submenu_page_callback' ); } function view_tasks_submenu_page_callback() { // html } add_action( 'admin_menu', 'wpdocs_register_my_setting' ); And I want to add a meta box to this page only. function cd_meta_box_add() { add_meta_box( 'in-progress-metabox', 'In Progress', 'render_task_in_progress_metabox', 'task', 'normal', 'high' ); } function render_task_in_progress_metabox() { // html } add_action( 'add_meta_boxes', 'cd_meta_box_add' ); But I cannot seem to find the correct answer for this. Again, I only want to add …
I've seen people recommending to edit the wordpress default Walker to change the menu markup and create your own. The problem with this is that I would like to change the markup of the submenu and leave the menu as it is. In the walker function I only saw the functions start_lvl and end_lvl regarding the submenu creation. The functions itself lack of very useful comments... so I understood that lvl means "level" and with that they mean "sub-menu"... But …