Articles of walker

Limit Custom Crawler to front end only

I am using the following custom walker to hide the Login and Register pages from my navmenu created with wp_get_nav_menu_items….. function wpse31748_exclude_menu_items( $items, $menu, $args ) { // Iterate over the items to search and destroy if ( is_user_logged_in() ) { $registerpage = get_page_by_title( ‘Register’ ); $loginpage = get_page_by_title( ‘Login’ ); foreach ( $items as […]

Term Checklist Walker – Disable Parent Categories

Currently I have a structure where the top level categories are acting like landing pages, so they should have no posts directly assigned to them. What I would like to do is disable the top level terms and only allow the user to check sub-terms (children). I’ve found a walker which transforms checkboxes to radio […]

Get top items number from wordpress menu

I’ve made a menu in WordPress backend with 3 levels depth. (four main tabs with two sub level items) I would like to know how I can get the number of tabs created automatically and add this number to a class on the ul (i.e: .item-4) Any ideas? I’m already using a custom walker.

Use wp_nav_menu to display ALL pages

I am currently building a wordpress theme. For the menu, I just want to display all the pages that are created in the order that they are created in (i.e. I don’t want users to have to go into the ‘menu’ section of the site and create their own). I tried using wp_page_menu and this […]

Removing <li> from Comment

I’m making a custom comment template, and I do not wish to use a list to display comments. By default, WordPress puts the following at the end of every comment: </li><!– #comment-## –> I know I could hack the core wp-includes/comment-template.php, but that would leave me to not be able to update normally. Is there […]

Run a filter when a walker runs

Is there any way to run a particular add_filter function whenever a specific Walker_Nav_Menu class runs? The function always needs to run when the walker goes, and I’d like them to share variables, in particular $column_limit. The function should run just before all the other stuff in the walker, in order to add classes to […]

Insert HTML inside link in a walker

I’ve got a custom nav walker that (theoretically) pulls the featured image from the most recent post in a custom taxonomy, and displays the the image after the link in a wp_list_categories. The problem is I need the image to display above the category name, within the link. I can’t seem to figure out how […]

Main Menu and Sub Menu Items for Footer

So I’m currently trying to figure out how to display both my main menu items and my submenu items separately in my footer. I want to display them both in separate columns (bootstrap) and am having trouble displaying them. Here’s what I have <div class=”col-sm-3 col-md-3″> <ul> <?php wp_nav_menu( array( ‘theme_location’ => ‘primary’, ‘depth’ => […]

Get number of root elements in walker class

I extended Walker_Nav_Menu class as below class YPE_custom_navwalker extends Walker_Nav_Menu{} I want use the get_number_of_root_elements( $elements ) function that place in to Walker class within my new class YPE_custom_navwalker i want use that function for showing the number of root elements within start_el function i used this code below but don’t work echo $args->walker->get_number_of_root_elements($elements);

has_children in custom nav_walker

I am trying to create custom menu nav walker. I added below code function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { $id_field = $this->db_fields[‘id’]; if ( is_object( $args[0] ) ) { $args[0]->has_children = ! empty( $children_elements[$element->$id_field] ); } return parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } As a result I can […]