Custom search filter causes menu and query_posts problems

Use is_main_query() to modify only the main query so menu will stay not affected. Try This: add_action( ‘pre_get_posts’, ‘fteh_pre_get_posts’ ); function fteh_pre_get_posts( $query ){ if( !is_admin() && $query->is_main_query() && isset( $query->query_vars[‘type’] ) ) $types = explode( ‘,’, $query->query_vars[‘type’] ); $query->set( ‘post_type’, $types ); return $query; }

wp_nav_menu remove class and id from li

If you look in the wp_nav_menu() function, you see the items are written by walk_nav_menu_tree(), which calls Walker_Nav_Menu to do the work (unless you specified your own walker class). This class contains a method start_el() that is called for each menu item. In this function, you see that the classes are filtered through nav_menu_css_class and … Read more

How to avoid wp_nav_menu() ID conflict?

The solution is not to call the same ‘theme_location’ more than once. Theme location is intended to represent an explicit location within the template. Just register a separate ‘theme_location’ for each separate location within the template that you want to display a nav menu. Consider your chosen ‘theme_location’ names to be semantic names, representing the … Read more

Making breadcrumb with wp_nav_menu

I couldn’t believe there is not a single FREE plugin available that does this. So I wrote my own function. Here you go. Just copy this to your functions.php: function my_breadcrumb($theme_location = ‘main’, $separator=” > “) { $theme_locations = get_nav_menu_locations(); if( ! isset( $theme_locations[ $theme_location ] ) ) { return ”; } $items = wp_get_nav_menu_items( … Read more

how to create a menu with all sub categories?

This depends on what kind of menu you are talking about: 1) If you are talking about “custom menus” (found in the Backend under Design -> Menus) you can do the following: Create a new function with the action hook add_category inside of this function, you can create a new post of type the menu … Read more

Check if page is in a certain menu

Here’s the function I wrote to figure this out. You give it a menu slug/name/ID and post/page ID and it returns TRUE if that post/page is in the specified menu and FALSE otherwise. Then it was just simply a matter of a quick if/else statement to check against the two menus and display the correct … Read more

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