0
votes

If you go to: http://joshuajohnson.co.uk/tarva/centres/

At the moment I am using the following query in my search file:

$args = array( 
  'post_type' => 'centre', 
  'paged' => $paged,
  'orderby' => 'title',
  'order' => 'ASC',
  'posts_per_page' => 6, //Limits the amount of posts on each page
  'post_title' => 'LIKE %'.$_POST['s'].'%' 
);
$loop = new WP_Query( $args ); 

However, if you search anything, the results page shows just first 6 posts of the post type ‘centre’. I’m using a while ( $loop->have_posts() ) : $loop->the_post(); loop to filter results.

I gather that it isn't using the input from the search field, but am not sure why? Any ideas?

A gist with the related pages: https://gist.github.com/jshjohnson/cb8c1000f8d0d9b16935

EDIT: If I remove 'posts_per_page' from the query entirely, the search yields no results every time

1

1 Answers

0
votes

I believe you should be searching using the 's' argument.

's' => $_POST['s']

not

'post_title' => 'LIKE %'.$_POST['s'].'%'

There are also a number of posts about this: