Add a submenu to wp_nav_menu
Just drag and drop menu items in admin area. Submenu will automaticly appears in html. Then you can style it with css as you wish. Dropdown or something else.
Just drag and drop menu items in admin area. Submenu will automaticly appears in html. Then you can style it with css as you wish. Dropdown or something else.
For anybody interested in the code to remove any class you want. I Just worked with the Roots theme and they did the replacement like below. You can just add the class you want to replace in the list. /** * Replace various active menu class names with “active” or nothing * */ function roots_wp_nav_menu($text) … Read more
On each (child) page, get the top-most parent, then display the according menu. Here is a blue-print of what I just described (you may have to change this and that to make it behave like you want it to). Simply put the following code where you currently have your menu set up (in your header.php … Read more
That’s because object properties are case sensitive, thus $post->ID is not the same as $post->id . Just by printing out these two you’ll notice the difference, or do a print_r of the $post object to see all of the available properties and methods.
Yes, very much possible and you don’t even have to add classes yourself. If you’re using wp_nav_menu, WordPress adds classes for every case the specific nav item is in. I’ll name the important classes for Publications (amongst others), based on where you clicked hypothetically: Publications – This is now the selected item, and will get … Read more
This appears to be a CSS related issue. You need to clear:both your <li> elements which contain your <a href=links…> Make sure you apply that clear property to your sub-menu <li> elements only and not your top level parent items. Without knowing or seeing the exact theme you are working with, be it custom or … Read more
Most of those are controlled by your theme support. The functionality does not come for “free” with WordPress, you need to implement the actual code. Once you have put together the code for your theme to support one of the features you can enable it with add_theme_support. for example, in functions.php: add_action( ‘after_setup_theme’, function () … Read more
Your conditional is always true. To understand why, consider what happens in this function when there is no post parent: function get_top_ancestor_id() { global $post; // no parent so this doesn’t run: // if($post->post_parent) { // $ancestors = array_reverse(get_post_ancestors($post->ID)); // return $ancestors[0]; // } return $post->ID; } Which simplifies to: function get_top_ancestor_id() { global $post; … Read more
Menus can be slightly confusing since there’s often JS and CSS interacting with different things. Looking at the twentytwelve theme, a quick method of achieving this would be to remove the CSS that is adding :hover display of the submenus. In style.css you would see .main-navigation ul li:hover > ul, on line 1,567. In your … Read more
Replace all occurrences of $current_user->user_login == ‘username’ with in_array(‘editor’, $current_user->roles). And you can remove the call to get_currentuserinfo(); as for the user information is available from the global variable $current_user. Here’s a code swap: add_action(‘_admin_menu’, ‘remove_editor_submenu’, 1); function remove_editor_submenu() { global $current_user; if(in_array(‘editor’, $current_user->roles)) { remove_action(‘admin_menu’, ‘_add_themes_utility_last’, 101); } } add_action(‘admin_init’, ‘remove_theme_submenus’); function remove_theme_submenus() { … Read more