WordPress Search

Your search form includes this:

<input type="hidden" name="post_type" value="postpage" />

So when your search page loads, the query variable ‘post_type’ is set to load posts of type ‘postpage’.

Since posts are of type ‘post’ and pages are of type ‘page’, neither of which are ‘postpage’, you do not get what you expected.

Next time, don’t use reserved query variables for GET or POST parameters.

But further to that, if you want to modify what the main query does, use the pre_get_posts filter, e.g.:

function search_filter($query) {
  if ( !is_admin() && $query->is_main_query() ) {
    if ($query->is_search) {
      $query->set('post_type', array( 'post', 'page' ) );
    }
  }
}

add_action('pre_get_posts','search_filter');

Other notes:

  • Excessive tag spam, it’s the equivalent of me introducing myself at the start of every sentence then saying goodbye, your fingers can only type so fast, save yourself the effort and make things easier to read
  • Use {} braces and indent accordingly, I know the codex sometimes has examples saying you should use it, but most editors will only brace match on {}. If you must use the if(): endif; syntax then stick to it and don’t mix the two
  • Always have 1 statement/command per line, when your error message says line 500, you don’t want to find 5 different things on that line to pick apart
  • Don’t use inline script attributes such as onblur, it’s bad and mixes behaviour and presentation. Look up the relevant jQuery events