Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Setting up a WP Query with a search

View parsed - Show only message text

Received: by 10.114.159.6 with SMTP id h6mr1469251wae.9.1239658865513;
        Mon, 13 Apr 2009 14:41:05 -0700 (PDT)
Return-Path: <wp-hackers-boun...@lists.automattic.com>
Received: from comox.textdrive.com (comox.textdrive.com [207.7.108.189])
        by gmr-mx.google.com with ESMTP id k32si2143867wah.2.2009.04.13.14.41.05;
        Mon, 13 Apr 2009 14:41:05 -0700 (PDT)
Received-SPF: neutral (google.com: 207.7.108.189 is neither permitted nor denied by best guess record for domain of wp-hackers-boun...@lists.automattic.com) client-ip=207.7.108.189;
Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 207.7.108.189 is neither permitted nor denied by best guess record for domain of wp-hackers-boun...@lists.automattic.com) smtp.mail=wp-hackers-boun...@lists.automattic.com
Received: from comox.textdrive.com (localhost [127.0.0.1])
	by comox.textdrive.com (Postfix) with ESMTP id 0BCC86202;
	Mon, 13 Apr 2009 21:41:01 +0000 (GMT)
Received: from localhost (localhost [127.0.0.1])
	by comox.textdrive.com (Postfix) with ESMTP id EF8B05E92
	for <wp-hack...@lists.automattic.com>;
	Mon, 13 Apr 2009 21:40:58 +0000 (GMT)
Received: from comox.textdrive.com ([127.0.0.1])
	by localhost (comox.textdrive.com [127.0.0.1]) (amavisd-new, port 10024)
	with LMTP id 89376-02-55 for <wp-hack...@lists.automattic.com>;
	Mon, 13 Apr 2009 21:40:51 +0000 (GMT)
Received: from mail-ew0-f159.google.com (mail-ew0-f159.google.com
	[209.85.219.159])
	by comox.textdrive.com (Postfix) with ESMTP id 729ED6194
	for <wp-hack...@lists.automattic.com>;
	Mon, 13 Apr 2009 21:40:50 +0000 (GMT)
Received: by ewy3 with SMTP id 3so2435262ewy.22
	for <wp-hack...@lists.automattic.com>;
	Mon, 13 Apr 2009 14:40:49 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.211.137.19 with SMTP id p19mr2306821ebn.88.1239658849121; Mon, 
	13 Apr 2009 14:40:49 -0700 (PDT)
In-Reply-To: <AEC8223E-668F-4458-9062-A1018C3E2EA0@indiana.edu>
References: <77c8b7bf0904131128u46a7555bu3969d8b5bacd4624@mail.gmail.com> 
	<AEC8223E-668F-4458-9062-A1018C3E2EA0@indiana.edu>
From: Simon Wheatley <si...@sweetinteraction.com>
Date: Mon, 13 Apr 2009 22:40:34 +0100
Message-ID: <77c8b7bf0904131440l4deca25akda6b7e13cb372...@mail.gmail.com>
Subject: Re: [wp-hackers] Setting up a WP Query with a search
To: wp-hack...@lists.automattic.com
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-BeenThere: wp-hack...@lists.automattic.com
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: wp-hack...@lists.automattic.com
List-Id: wp-hackers.lists.automattic.com
List-Unsubscribe: <http://lists.automattic.com/mailman/listinfo/wp-hackers>,
	<mailto:wp-hackers-requ...@lists.automattic.com?subject=unsubscribe>
List-Archive: <http://comox.textdrive.com/pipermail/wp-hackers>
List-Post: <mailto:wp-hack...@lists.automattic.com>
List-Help: <mailto:wp-hackers-requ...@lists.automattic.com?subject=help>
List-Subscribe: <http://lists.automattic.com/mailman/listinfo/wp-hackers>,
	<mailto:wp-hackers-requ...@lists.automattic.com?subject=subscribe>
Sender: wp-hackers-boun...@lists.automattic.com
Errors-To: wp-hackers-boun...@lists.automattic.com

On Mon, Apr 13, 2009 at 8:21 PM, SoJ Web <soj...@indiana.edu> wrote:
>
> Are you just trying to modify or override the default WP search? There are a
> few filters you can use to modify the query fairly extensively. The Search
> Everything plugin has some nice code that can give you an idea of working
> with that stuff:
>

Thanks for the suggestion. To (attempt to) clarify a little:

Currently I'm creating listings of recent posts in categories for use
on various templates by defining a WP_Query thus:

$args = array(
	'post_type' => $post_type,
	'what_to_show' => 'posts',
	'post_status' => 'publish',
	'posts_per_page' => $num_posts,
	'orderby' => 'modified',
	'order' => 'DESC',
	'cat' => $cat_ids,
);
$new_wp_query = new WP_Query( $args );

I was hoping for something similar, using WP_Query, which would allow
me to return posts as per a WP search but with the results restricted
to a particular set of categories. I'm fine with using the WHERE
filters on the SQL generated by the WP_Query and so I could do my SQL
LIKE stuff here, but I hoped it might be possible to reuse the
existing code in WP_Query which manages the WP search results to
generate my restricted search results. (Seems like less code
duplication.)

I thought it might be as simple as:

$args = array(
	's' => $search_string,
);
$search_wp_query = new WP_Query( $args );

...but that doesn't seem to be working for me. :(

Are you suggesting that I should kick off a WP_Query as per my first
example and then use the WHERE filters to mess with the resultant SQL?

Thanks again.

S


P.S. Search Everything is certainly a nicely coded plugin. :)


---
Sweet Interaction Ltd is Registered in England/Wales, no. 6610741
Registered office: 7 Malton Av, Manchester, M21 8AT
_______________________________________________
wp-hackers mailing list
wp-hack...@lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google