title: Modifying search function to exclude posts and limit results to 10 per page on front end only
body: <p>This problem is kind of two part. I have the solution to exclude posts from the search and limit the results to 10 results per page but the problem is it also affects the backend wp-admin area. So if i search for posts through the wp-admin area the posts will be excluded even though I only want this to occur for users who are not admin. This is the code I have for excluding posts and limiting the results to 10:</p>
  
  <pre><code>function SearchFilter($query) {
      if ($query-&gt;is_search) {
          $query-&gt;set('post_type', 'page');
      }
      return $query;
  }
  add_filter('pre_get_posts','SearchFilter');
  
  function change_wp_search_size($query) {
      if ( $query-&gt;is_search ) // Make sure it is a search page
          $query-&gt;query_vars['posts_per_page'] = 10;
  
      return $query;
  }
  add_filter('pre_get_posts', 'change_wp_search_size');
  </code></pre>
  
  <p>Now I have done a little bit of reading and research on stack and other sites and it looks like there is a way to only trigger these functions only after checking if admin is logged in. I'll reference to the <a href="https://codex.wordpress.org/Function_Reference/is_admin" rel="nofollow">wordpress codex</a> for the is_admin function </p>
  
  <p>This is the way I attempted to use the is_admin function which caused an http error 500. Please excuse me if the code is grossly incorrect:</p>
  
  <pre><code>if ( !is_admin() ) {
  function SearchFilter($query) {
  if ($query-&gt;is_search &amp;&amp; !is_admin() ) {
  $query-&gt;set('post_type', 'page');
  }
  return $query;
  }
  add_filter('pre_get_posts','SearchFilter');
  if ( !is_admin() ) {
  function change_wp_search_size($query) {
  if ( $query-&gt;is_search &amp;&amp; !is_admin() )
  $query-&gt;query_vars['posts_per_page'] = 10;
  return $query;
  }
  add_filter('pre_get_posts', 'change_wp_search_size');
  </code></pre>
  
  <p>I'm hoping that I'm close and just need some tweaking for the code </p>
  
  <p>Edit:
  So now this is what i have for both functions. I know its my php code which is the problem can you help further please:</p>
  
  <pre><code>function SearchFilter($query) {
  if ( is_admin () ) {
  return $query;
  }
  else {
  ($query-&gt;is_search) {
  $query-&gt;set('post_type', 'page');
  }
  return $query;
  }
  add_filter('pre_get_posts','SearchFilter');
  
  function change_wp_search_size($query) {
  if ( is_admin () ) {
  return $query;
  }
  if ( $query-&gt;is_search ) // Make sure it is a search page
  $query-&gt;query_vars['posts_per_page'] = 10;
  
  return $query;
  }
  add_filter('pre_get_posts', 'change_wp_search_size');
  </code></pre>
  
  <p>EDIT 2: Pastebin of the entire function.php file <a href="http://pastebin.com/tTEnHGp2" rel="nofollow">http://pastebin.com/tTEnHGp2</a></p>