Custom walker pulldown display current page

WordPress add “current-menu-item” class for the active menu item, you could check if this class is set and the set the option for that item be selected. class Walker_Nav_Menu_Dropdown extends Walker_Nav_Menu { function start_lvl($output, $depth) { } function end_lvl($output, $depth) { } function start_el($output, $item, $depth, $args) { // Here is where we create each … Read more

Help with output of post classes using apply_filters

Solved it with generous help using join()… function start_el(&$output, $page, $depth = 0, $args = array(), $id = 0) { if ( $depth ) $indent = str_repeat(“\t”, $depth); else $indent=””; extract($args, EXTR_SKIP); $output .= $indent . ‘<li id=”item_’.$page->ID.'” class=”‘.join( ” “, get_post_class( “”, $page->ID )).'”><span>’.apply_filters( ‘the_title’, $page->post_title, $page->ID ).'</span>’; }

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

How to append something before final tag in walker class?

You should check the $depth argument to make sure the search form only appears at a certain depth/level, e.g. if( 0 === $depth ) { … } I personally would place the search form outside the <ul> though as I don’t think it’s valid HTML. It would hurt your site’s accessibility. Alternatively, wrap it in … Read more

Custom Walker menu depth opening problem

I Try to find how to collapse all cat by default in other word In that case, then try this script (replace the one you have now): <script> ( function ( $ ) { $( ‘li.has-children’, ‘#cat-drop-stack’ ).on( ‘click’, ‘> a span.caret-icon’, function ( e ) { e.preventDefault(); var self = $( this ), submenu … Read more

Page thumbnail doesn’t display on navigation

the_post_thumbnail() echos content. This is explicitly stated in the Codex, and the function name follows the WordPress convention (mostly) that function names starting with the_ echo content. Display the Featured Image (previously called Post Thumbnails) for the current post, as set in that post’s edit screen. The thumbnail will display as soon as that line … Read more