Count Level 1 Childs for Custom Nav Walker WordPress

I’m trying to make my logic like this: calling below code inside function start_el( &$output, $item, $depth, $args ) { $this->sub_items = 0; // declared variable as private $sub_items = 0 above inside class if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $args->theme_location ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] … Read more

Check in walker if current page is descendant

It seems to me, you are trying to get the ancestors by the actual post, while you most likely should get the ancestors according to the menu item. Why? Because setting up a hierarchy in the menu does not change the actual post, especially the post_parent property won’t be changed – in short: (other) post … Read more

Creating custom Menu for custom theme

You can remove the container and ul tag like this: <?php wp_nav_menu( array( ‘container’ => ”, ‘items_wrap’ => ‘%3$s’ ) ); ?> Now you can see an architecture like this: <li> <a href=”#”>item</a> </li> And i think you could adjust your stylesheet to adapt “li” tag. Hope it helps.

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

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