remove class “sub-menu” from wordpress drop down menu

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

Can I have a different menu for each parent page?

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

a better menu, menu options assistance for WP

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

Admin: sub menu doesnt display under apperance when activate my themes

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

get_the_title() gets printed out twice

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

WordPress Remove Submenus

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