Can’t extend some core classes

You can extend it, but the class definition and any code that uses it, can’t run outside of the admin area. Wrap your class in this conditional: if ( is_admin() ) { … } If you are trying to use this on the frontend or other non-Admin areas, do not do that. Generally, classes WordPress … Read more

Create wordpress header with custom logo in between the menu splitting the menu into two equal parts [closed]

After some testing I found the best way is to use a walker. For this example lets say that this is the code that calls our menu wp_nav_menu([ ‘container’ => false, ‘theme_location’ => ‘right-side-top-menu’, ‘walker’ => new Menu_Middle_Logo() ]); Now for our walker, there isn’t an easy way to determine which of the parent menu … Read more

Make wp_list_pages print slugs instead of titles

I would recommend using get_pages() rather than wp_list_pages() for this purpose. The get_pages() function will return an array of objects of Pages, and you can use the array data to build your own HTML list. e.g.: <?php // Wrap in a function, for later output; function wpse47989_list_pages() { // Get an array of pages using … Read more

Limit Custom Crawler to front end only

You can try the !is_admin() so your code would be: function wpse31748_exclude_menu_items( $items, $menu, $args ) { // Iterate over the items to search and destroy if ( !is_admin() && is_user_logged_in() ) { $registerpage = get_page_by_title( ‘Register’ ); $loginpage = get_page_by_title( ‘Login’ ); foreach ( $items as $key => $item ) { if ( $item->object_id … Read more

Get top items number from wordpress menu

You can use the wp_get_nav_menu_object to retrieve the menu as an object, which you can subsequently establish the length of. Like this: $wpse140949_menu = wp_get_nav_menu_object( ‘your-menu-name-or-slug’ ); $tabcount = $wpse140949_menu->count; You can the use this on your call to wp_nav_menu: wp_nav_menu ( array ( ‘menu_class’ => ‘item-‘ . $tabcount, …. ));

Insert HTML inside link in a walker

You can try to skip the CategoryThumbnailWalker and use instead the list_cats filter. Here’s an untested example: add_filter( ‘list_cats’, ‘wpse_149898_list_cats’, 99, 2 ); wp_list_categories(array( “child_of” => get_queried_object_id(), “depth” => 1, “hide_empty” => false, “hierarchical” => 1, “orderby” => “name”, “pad_counts” => 0, “post_type” => “projects”, “show_count” => 0, “show_option_none” => “”, “taxonomy” => “project-category”, “title_li” … Read more

Run a filter when a walker runs

If all of it is your own code then it would be reasonable to just implement that as part of walker. If you need to add a filter while third party walker runs you could probably: Add it at wp_nav_menu_args hook, checking if walker is set to that: add_filter( ‘wp_nav_menu_args’, function( $args ) { if … Read more

How to construct a custom html for submenus

Okays.. i’ve solved this in my own way. i have added the following function in functions.php file class ik_walker extends Walker_Nav_Menu{ //start of the sub menu wrap function start_lvl(&$output, $depth) { $output .= ‘<div class=”dropdownContain”> <div class=”dropOut”> <div class=”triangle”></div> <ul>’; } //end of the sub menu wrap function end_lvl(&$output, $depth) { $output .= ‘ </ul> … Read more

Get number of root elements in walker class

I’m not sure if this is what you’re after. You can use $this to reference the current walker instance. class YPE_custom_navwalker extends Walker_Nav_Menu { public function start_lvl(&$output, $depth=0, $args=array()) { $items = wp_get_nav_menu_items( $args->menu->term_id ); echo $this->get_number_of_root_elements( $items ); parent::start_lvl(&$output, $depth,$args); } }

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