Search breaks when querying main loop for category

For your second example, I think you’re initiating your Loop incorrectly. You’re declaring $query, which hasn’t been globalized? // Search is working, querying is not global $query_string; // required $posts = query_posts($query_string.’&posts_per_page=3&cat=$catid’); while ( $query->have_posts() ) : $query->the_post(); Try omitting $query from your Loop initiation? // Search is working, querying is not global $query_string; // … Read more

AJAX search posts and pages

The error seams to come from another source, not your query. You don’t use wp_options table. So maybe skipping $wpdb->show_errors(); $wpdb->print_error(); would make things even work. But probably there is an error somewhere else. To get an overview how to create AJAX search helper, you can check here: http://www.wpcodelab.com/archives/create-a-custom-ajax-search-for-wordpress

Installing Solr for dedicated search

Make sure you use the solr port and hostname provided to you in your opensolr account area for your collection. The default free opensolr server, is running on port 8180. Every single aspect of connecting to the opensolr collections is being explain throughly, through the blog, and through videos. Opensolr is intended to give a … Read more

Customising the search function?

You can use pre_get_posts hoot to filter the search query to selected sectors only, something like this: function Search_with_in_a_tax( &$query ) { if ( is_search() && isset($_GET[‘sector_array’])) { $tax_query = array( array( ‘taxonomy’ => ‘news’, ‘terms’ => $_GET[‘sector_array’], ‘field’ => ‘term_id’, ) ); //turn it into a WP_Tax_Query object $tax_query = new WP_Tax_Query($tax_query); $query->set(“tax_query”, $tax_query); … Read more

filter custom post type by meta key in dashboard

I’m assuming you’ve used the method in the question linked to and are using the restrict_manage_posts filter. add_action( ‘restrict_manage_posts’, ‘my_search_box’ ); function my_search_box() { // only add search box on desired custom post_type listings global $typenow; if ($typenow == ‘product’) { //On custom post type ‘product’ admin page. //Add code for search box here } … Read more

How to stick custom post at the top in search results

A simple hack. Edit: putting the featured post ids in an array and checking that array in the main loop. global $post; $post_IDs = array(); foreach($post_info as $post_info_obj) { $post_IDs[] = $post_info_obj->ID; } $featured_IDs = array(); $query1 = new WP_Query(array(‘meta_key’=>’sticky’,’meta_value’=>’featured’,’post__in’=>$post_IDs)); while($query1->have_posts()) { $query1->the_post(); $featured_IDs[] = $post->ID; get_property_info_li($post); } First thing do to in the main … Read more