How to add menu to Dashboard that can be viewed by all users

You have to use the right capability for this. You chose manage_options, which by default only users with an Administrator user role have. So, change it to read or exist, for instance, and every user will be able to see and access the menu. add_dashboard_page( ‘custom menu title’, ‘Test’, ‘read’, ‘custompage’, ‘my_custom_menu_page’, plugins_url( ‘test/images/icon.png’ ), … Read more

Add Page ID class to nav menu items

We can add custom nav menu classes through the nav_menu_css_class filter. Example: The following should add the CSS class wpse-object-id-{object_id} to the <li> tags: // Add filter add_filter( ‘nav_menu_css_class’, ‘wpse_menu_item_id_class’, 10, 2 ); // Your navigational menu wp_nav_menu( $args ); // Remove filter remove_filter( ‘nav_menu_css_class’, ‘wpse_menu_item_id_class’, 10, 2 ); where we define the filter callback … Read more

Directing a page to a default subpage

Using WordPress custom nav menus create a menu and add the “General” page 2 times. The first as the parent and the second as the first child then add the rest of the pages as childs under the first General. Change the title in the first general to movies then on the front end when … Read more

Exclude one item from wp_list_pages( $args );

There’s a filter called wp_list_pages_exclude that you could possibly hook into (put this in your functions.php): function filter_wp_list_pages($exclude){ $exclude[] = 56; return $exclude; } add_filter(“wp_list_pages_excludes”, “filter_wp_list_pages”);

wordpress nav menu using twitter bootstrap

For a copy paste solution check this custom Walker out: http://goodandorgreat.wordpress.com/2012/01/12/update-2-using-twitter-bootstrap-dropdown-menus-with-wordpress/ It’s missing one or two things like data-toggle=”dropdown” and <b class=”caret”></b>. It should be quite easy to figure that out, but here’s my modified version: https://gist.github.com/1817371 Hope that helps.

How do I fix this error: Warning: invalid argument supplied for foreach()?

This usually happens when you are trying to do admin navigation stuff and you aren’t hooked into admin_menu. If you hook in before that, $menu hasn’t been created yet. add_action(‘admin_menu’, ‘my_plugin_add_menu’); function my_plugin_add_menu(){ $ptype=”my_post_type”; $ptype_obj = get_post_type_object( $ptype ); add_submenu_page( ‘my-menu-item’, $ptype_obj->labels->name, $ptype_obj->labels->all_items, $ptype_obj->cap->edit_posts, “edit.php?post_type=$ptype” ); }

Custom Nav Walker menu – Display children count

I sort of added onto @Giri’s answer by using array_map and array_count_values. if this helps anyone in the future. I didn’t wish to use a counter and a foreach loop for something so simple. function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { if ($item->hasChildren) { $locations = get_nav_menu_locations(); … Read more

How to get a separate child menu?

Found the solution. Put this in your function.php file: // add hook add_filter( ‘wp_nav_menu_objects’, ‘my_wp_nav_menu_objects_sub_menu’, 10, 2 ); // filter_hook function to react on sub_menu flag function my_wp_nav_menu_objects_sub_menu( $sorted_menu_items, $args ) { if ( isset( $args->sub_menu ) ) { $root_id = 0; // find the current menu item foreach ( $sorted_menu_items as $menu_item ) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)