functions.php adding item to end of menu. I want to change position

Using PHP operators you can change: $items .= ‘<li class=”register”><a href=”‘ . $registration_topmenu_url . ‘” class=”section-button”>’ . stripslashes($reg_widget[‘registrationtopmenutext’]) . ‘</a></li>’; To $rbutton = ‘<li class=”register”><a href=”‘ . $registration_topmenu_url . ‘” class=”section-button”>’ . stripslashes($reg_widget[‘registrationtopmenutext’]) . ‘</a></li>’; $items = $rbutton . $items;

How to get submenu of admin menu?

You can use the global variable $submenu. Example to list the child menu of parent post menu:- function admin_init_callback() { global $submenu; $sumenu_list = $submenu[‘edit.php’]; var_dump($sumenu_list); //array of submenu } add_action(‘admin_init’, ‘admin_init_callback’, 999); Profi660 EDIT: Not needed to be used with admin_init hook. I used this in my plugin page and worked very well.

Secondary menu in WP 4.5

Yes, you need to add this: add_action( ‘init’, ‘my_custom_menus’ ); function my_custom_menus() { register_nav_menus( array( ‘primary-menu’ => __( ‘Primary Menu’ ), ‘secondary-menu’ => __( ‘Secondary Menu’ ) ) ); } to your functions.php. It will create the menu locations in the menu admin area. More info: https://codex.wordpress.org/Navigation_Menus In your theme, usually in header, you need … Read more

Need to revert to an older version of wordpress

In order to downgrade your wp version , first download your desired version from the link below https://wordpress.org/download/release-archive/ Then follow the steps Deactivate all plugins Logout of wordpress Delete the WP-ADMIN WP-INCLUDES folders via FTP Transfer the files from the downngraded wp version to your site via FTP EXCEPT WP-CONTENT Now login to wordpress , … Read more

Get css class of menu item in custom menu structure

What you’re getting is an array so you need to implode() them – the Walker_Nav_Menu has something like this: $class_names = esc_attr( implode( ‘ ‘, apply_filters( ‘nav_menu_css_class’, array_filter( $classes ), $item ) ) ); So you can modify your foreach to implode them in a similar fashion $class = esc_attr( implode( ‘ ‘, apply_filters( ‘nav_menu_css_class’, … Read more

menu-item class missing on wordpress menu

The default fallback in wp_nav_menu for a menu that doesn’t exist/isn’t registered is wp_page_menu, which unfortunately does not support the same arguments/implement the same level of “customisability” – you either need to create a custom fallback, or remove the fallback entirely (so that the user is forced to set a menu).

How to add search to menu?

Use the get_search_form filter: add_filter(‘wp_nav_menu_items’,’add_search_box_to_menu’, 10, 2); function add_search_box_to_menu( $items, $args ) { if( $args->theme_location == ‘primary’ ) return $items. get_search_form(); return $items; } add_filter( ‘get_search_form’, ‘custom_search_form’ ); function custom_search_form( $form ) { ob_start(); // get_stylesheet_directory will get // the main directory of the child theme include( get_stylesheet_directory() . ‘/searchform.php’ ); $form = ob_get_clean(); return … Read more

Adding a section in line at the end of the main navigation menu in php

https://developer.wordpress.org/reference/hooks/wp_nav_menu_menu-slug_items/ function my_nav_menu_primary_navigation($items, $args) { $items .= ‘<li>Hello :D</li>’; return $items; } add_filter( “wp_nav_menu_{MENU SLUG}_items”, “my_nav_menu_primary_navigation”, 10, 2 ); find {MENU SLUG} EDIT: The “wp_nav_menu_menu-slug_item” filter runs at the end near the end of wp_nav_menu, $ items is a string containing the HTML extructura the menu and $ args are the arguments that you passed … Read more