Walker_Nav_Menu Add Strings and Class Name

This drove me crazy. Here is the solution, hope someone find it useful or suggest a better and shorter solution: class sstmyp_Walker_Nav_Menu extends Walker_Nav_Menu { function display_element($element, &$children_elements, $max_depth, $depth=0, $args, &$output) { $id_field = $this->db_fields[‘id’]; // add custom class and carets to menu has children if(in_array(“menu-item-has-children”, $element->classes)) { $element->classes[] = ‘dropdown’; $element->title .= ‘ … Read more

Using wp_list_categories or other function inside a menu walker?

Here is my code to edit menu item, maybe it can help you: class SB_Menu_Walker extends Walker_Nav_Menu { /** * What the class handles. * * @see Walker::$tree_type * @since 3.0.0 * @var string */ public $tree_type = array(‘post_type’, ‘taxonomy’, ‘custom’); /** * Database fields to use. * * @see Walker::$db_fields * @since 3.0.0 * … Read more

Show post titles within WordPress bootstrap Dropdown menu

Thank you for our reply i solved my problem i used WordPress loop query for showing last fout posts in four column as below if (!empty($item->divideto_4)) { $col = 3; $divide_to = 12 / $col; //4 $my_query = “showposts = “.$divide_to; $my_query = new WP_Query($my_query); while ($my_query->have_posts()) : $my_query->the_post(); $item_output .= ‘<div class=”col-sm-‘.$col.'”>’; $item_output .= … Read more

Cannot add home page url to menu with #

This is what you have to do: Change the <a href=”#section”></a> to <a href=”http://127.0.0.1/#section”></a> From what i understand home is http://127.0.0.1 and on home #section is located not on http://127.0.0.1/second-page so from http://127.0.0.1/second-page you have to go back to http://127.0.0.1 that goes straight to #section that is located on http://127.0.0.1 That should do the trick

Custom menu with Walker class – what should the $db_fields be?

If you want to build your own custom nav menu you should be extending the Walker_Nav_Menu class, not the Walker class. When building a custom menu walker the $db_fields should be what the default Walker_Nav_Menu class has: $db_fields = array (‘parent’ => ‘menu_item_parent’, ‘id’ => ‘db_id’); When building the navigation link for a menu item, … Read more