Ticket #27042: nav-menu.php.37802.WP_QUERY.patch
| File nav-menu.php.37802.WP_QUERY.patch, 1.6 KB (added by , 10 years ago) |
|---|
-
nav-menu.php
70 70 71 71 } elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) { 72 72 if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) { 73 query_posts(array( 73 $search_results_query = new WP_Query( array( 74 'no_found_rows' => true, 75 'update_post_meta_cache' => false, 76 'update_post_term_cache' => false, 74 77 'posts_per_page' => 10, 75 78 'post_type' => $matches[2], 76 79 's' => $query, 77 ) );78 if ( ! have_posts() )80 ) ); 81 if ( ! $search_results_query->have_posts() ) { 79 82 return; 80 while ( have_posts() ) { 81 the_post(); 83 } 84 while ( $search_results_query->have_posts() ) { 85 $post = $search_results_query->next_post(); 82 86 if ( 'markup' == $response_format ) { 83 $var_by_ref = get_the_ID();87 $var_by_ref = $post->ID; 84 88 echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args ); 85 89 } elseif ( 'json' == $response_format ) { 86 90 echo wp_json_encode( 87 91 array( 88 'ID' => get_the_ID(),89 'post_title' => get_the_title( ),90 'post_type' => get_post_type(),92 'ID' => $post->ID, 93 'post_title' => get_the_title( $post->ID ), 94 'post_type' => $matches[2], 91 95 ) 92 96 ); 93 97 echo "\n"; 94 98 } 95 } 99 } 96 100 } elseif ( 'taxonomy' == $matches[1] ) { 97 101 $terms = get_terms( $matches[2], array( 98 102 'name__like' => $query,