As the title suggests, I'm trying to find a post through its post_content
.
How can I do it?
Thanks
Example: SELECT * FROM DBname WHERE post_content LIKE '%phrase%'
Here is the code. $term_ids=array(); $cat_Args="SELECT * FROM $wpdb->terms WHERE name LIKE '%". $_REQUEST['s'].
query_posts() is a way to alter the main query that WordPress uses to display posts. It does this by putting the main query to one side, and replacing it with a new query. To clean up after a call to query_posts, make a call to wp_reset_query() , and the original main query will be restored.
Alternatively, (and since it is specified in question) you can achieve this by actually using "WP_Query" class:
// The Query
$my_query = new WP_Query( array(
'post_type' => 'post',
's' => 'phrase'
));
// The Loop
while ( $my_query->have_posts() ) {
$my_query->the_post();
get_content();
//...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With