john_yourspace
asked on
WP Query
Hi guys,
Whats the best way to search a custom post for a key word
I have this so far
Whats the best way to search a custom post for a key word
I have this so far
$temp = $wp_query;
//$wp_query= null;
if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
else { $paged = 1; }
$args = array('post_type' => 'business','posts_per_page'=>9,'order' => 'ASC','paged'=>$paged);
if(isset($_GET['keyword']) && $_GET['keyword'] !=='')
{
}
$wp_query = new WP_Query($args);
while ($wp_query->have_posts()) : $wp_query->the_post();
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
if($thumbnail[0])
{
global $thumbnail;
global $post;
ASKER
You should use the Search Parameter of the WP_Query 's'.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi john_yourspace,
two questions:
1) Did parameter s solve your problem?
2) Did you read my Comment ID: 40029265?
Quote: "You should use the Search Parameter of the WP_Query 's'."
two questions:
1) Did parameter s solve your problem?
2) Did you read my Comment ID: 40029265?
Quote: "You should use the Search Parameter of the WP_Query 's'."
ASKER
thanks for the help
This hook is called after the query variable object is created, but before the actual query is run.
The pre_get_posts action gives developers access to the $query object by reference (any changes you make to $query are made directly to the original object - no return value is necessary).
Open in new window