title: Wordpress gives 404 error with a custom query
body: <p>There are lots of questions similar to this, but none seem to be a fix for me sadly...</p>
  
  <p>I am trying to filter results by using a custom query within Wordpress, via the Wordpress' <code>query_vars</code>, however <a href="http://gradehack.com/?subject=15" rel="nofollow noreferrer">I instead get a 404 error</a>. This error only occurs when the query I enter in the URL is one of those that I've added to the custom query functions.php function.</p>
  
  <h2>functions.php</h2>
  
  <pre><code>function create_posttype_modules() {
  
      register_post_type( 'modules',
          array(
              'labels' =&gt; array(
                  'name' =&gt; __( 'Modules' ),
                  'singular_name' =&gt; __( 'Module' ),
              ),
              'public' =&gt; true,
              'has_archive' =&gt; true,
              'rewrite' =&gt; array('slug' =&gt; 'modules'),
              'has_archive' =&gt; true,
              'taxonomies' =&gt; array( 'post_tag', 'category' ),
              'supports' =&gt; array('title'),
          )
      );
  }
  add_action( 'init', 'create_posttype_modules' );
  
  
  function add_my_var($public_query_vars) {
      $public_query_vars[] = 'subject';
      $public_query_vars[] .= 'orderselected';
      return $public_query_vars;
  }
  add_filter('query_vars', 'add_my_var');
  </code></pre>
  
  <h2>Form excerpt used on page</h2>
  
  <pre><code>    &lt;?php
  
  echo '&lt;form id="order" action="' . esc_url( home_url( "/" ) ) . '" method="get"&gt;';
  ?&gt;
    &lt;input type="hidden" name="subject" value="&lt;?php echo htmlspecialchars($_GET['subject']);?&gt;"&gt;
    &lt;select name="orderselected" onchange='this.form.submit()'&gt;
      &lt;option value="name" &lt;?php echo get_query_var('orderselected') == 'none' ? 'selected' : ''; ?&gt;&gt;Select&lt;/option&gt;
      &lt;option value="name" &lt;?php echo get_query_var('orderselected') == 'name' ? 'selected' : ''; ?&gt;&gt;Name&lt;/option&gt;
      &lt;option value="mean" &lt;?php echo get_query_var('orderselected') == 'mean' ? 'selected' : ''; ?&gt;&gt;Mean grade&lt;/option&gt;
      &lt;option value="first" &lt;?php echo get_query_var('orderselected') == 'first' ? 'selected' : ''; ?&gt;&gt;1st %&lt;/option&gt;
      &lt;option value="twoone" &lt;?php echo get_query_var('orderselected') == 'twoone' ? 'selected' : ''; ?&gt;&gt;2:1 %&lt;/option&gt;
      &lt;option value="twotwo" &lt;?php echo get_query_var('orderselected') == 'twotwo' ? 'selected' : ''; ?&gt;&gt;2:2 %&lt;/option&gt;
      &lt;option value="third" &lt;?php echo get_query_var('orderselected') == 'third' ? 'selected' : ''; ?&gt;&gt;3rd %&lt;/option&gt;
      &lt;option value="fail" &lt;?php echo get_query_var('orderselected') == 'fail' ? 'selected' : ''; ?&gt;&gt;Fail %&lt;/option&gt;
    &lt;/select&gt;
  
      &lt;noscript&gt;
          &lt;input type="submit" value="View" /&gt;
      &lt;/noscript&gt;
  &lt;/form&gt;
  </code></pre>
  
  <h2>I've had this working on a sub-page</h2>
  
  <p>I have had this working on a sub-page (with only other minor difference being I changed the <code>cat</code> query to <code>subject</code>) <a href="http://maxbeech.com/exeterentrepreneurs/gradehack/?orderselected=&amp;cat=17#" rel="nofollow noreferrer">within a page here</a>. But having transferred WP and made the gradehack page the homepage, the problem has arisen.</p>
  
  <p>Thanks so much for your help!</p>