Add Thumbnail to wp_list_categories()

The original question uses get_tax_meta() which does not exist in WordPress core but may be a custom function created by the asker. In this case we could switch it out just as well with get_term_meta(). You could try this: class List_Category_Images extends Walker_Category { function start_el( &$output, $category, $depth = 0, $args = array(), $id … Read more

Adding html elements to wp nav menu

I made a dynamic menu using this code: //add login/logout link to menu add_filter(‘wp_nav_menu_items’, ‘wps_add_login_logout_link’, 10, 2); function wps_add_login_logout_link($items, $args) { $login = __(‘Sign in’); $logout = __(‘Sign out’); $menu_id = ’15’; $menu_id2 = ’16’; if ( ! is_user_logged_in() ) $link = ‘<a href=”‘ . site_url(‘log-in-log-out’) . ‘”>’ . $login . ‘</a>’; else $link = … Read more

Custom nav walker with different output depending on depth

Sounds like you want to check the $depth variable. A depth of 0 is a top level item, a depth of 1 is a child of a top level item, etc. So in keeping with your current code, you could factor out that logic this way: $format=”%1$s<a%2$s><div>%3$s%4$s%5$s</div></a>%6$s”; if( $depth > 0 ) $format=”%1$s<a%2$s><div class=”flintstone-nav”>%3$s%4$s%5$s</div></a>%6$s”; $item_output … Read more

Adding a class (arrows) to main menu links that have children?

There are two ways of doing this: Javascript. You could use JQuery to select the <li> that have <ul> children of class ‘sub-menu’, inserting content, or appending a CSS class which you then style. For example: $(‘.sub-menu’).parent().addClass(‘myclass’) PHP, a new walker function. Copy the code from wp-includes/nav-menu-template.php (until approx line 109) into your themes functions.php … Read more

Show top-level parent with submenu menu walker

You can try to skip the following if-condition in the start_el() method in your child_menu_walker class: if ($item->menu_item_parent != $parent_item_id ) { //… } which is equal to: if ($item->menu_item_parent != 0 ) { //… } since you have $parent_item_id = 0. So it looks like this condition is filtering out your top-level parent. You … Read more

Adding Post Counts to Menu (Nav) Programmatically?

WordPress’ get_categories() function returns an array of category objects, each of which has a “count” property for the number of posts in that category. So something like this would get you a list of links to category pages: $categories = get_categories(); $markup = ‘<ul>’; foreach( $categories as $category ) { $catName = $category->category_nicename; $count = … Read more

Walker class: Problems with understanding how walk() method can be called without error

Per comments, it’s called with call_user_func_array, so the 1st 2 elements get assigned to the declared arguments $elements and $max_depth, leaving the third element ($r which is the original $args) to be assigned via array_slice to $args. Eg function wpse172812( $elements, $max_depth ) { $args = array_slice(func_get_args(), 2); error_log(“elements=$elements, max_depth=$max_depth, args=” . print_r( $args, true … Read more

Walker_Nav_Menu: put custom code between a particular

You need to make your own walker menu (i am guessing you already know that), and the best way i think is overriding the function that ends each menu item which is end_el : class logo_in_middle_Menu_Walker extends Walker_Nav_Menu { public $menu_location = ‘primary’; function __construct($menu_location_var) { // parent class doesnt have a constructor so no … Read more

Adding attributes to link in wp_nav_menu using custom Walker function

You want to modify the start_el method as you did the start_lvl one. At its most basic it would mean altering this line: $item_output .= ‘<a’. $attributes .’>’; To look like this one: $item_output .= ‘<a class=”dropdown-toggle” data-toggle=”dropdown”‘. $attributes .’>’; It looks like you will need more complicated logic to avoid inserting that string in … Read more

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