I need to do a WP_Query
with a LIKE
on the post_title
.
I started with this regular WP_Query
:
$wp_query = new WP_Query(
array (
'post_type' => 'wp_exposants',
'posts_per_page' => '1',
'post_status' => 'publish',
'orderby' => 'title',
'order' => 'ASC',
'paged' => $paged
)
);
But what I actually want to do looks like this in SQL:
$query = "
SELECT *
FROM $wpdb->posts
WHERE $wpdb->posts.post_title LIKE '$param2%'
AND $wpdb->posts.post_type="wp_exposants"
ORDER BY $wpdb->posts.post_title
";
$wpdb->get_results($query);
The output prints the results i’m excpecting, but I use the regular <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
to display the results.
And that is not working with $wpdb->get_results()
.
How can I achieve what I described here?