• Resolved andrejcremoznik

    (@andrejcremoznik)


    I’m working on a site with a custom post type for movies. This post type includes multiple taxonomies and custom fields by which I need to filter the query results.

    So I made a filter form and registered my custom vars. In functions.php I have:

    function extra_query_vars($vars) {
    	array_push($vars, 'date_from', 'date_to');
    	return $vars;
    }
    add_filter('query_vars', 'extra_query_vars');

    When I go to /movie-entries/?date_from=2011-12-01&date_to=2011-12-31
    and do var_dump($wp_query) my 2 custom vars aren’t present.

    If I go to /movie-entries/page/2/?date_from=2011-12-01&date_to=2011-12-31, the ‘paged’ value is present but my custom vars still aren’t there.

    So I’m assuming it has something to do with permalinks and my nginx configuration. I’d really appreciate some help here since rewrite rules are beyond me. So …

    1. I have permalinks turned on
    2. In nginx I’m rewriting urls with location / { try_files $uri $uri/ index.php; }
    3. I’m not rewriting my custom vars. Should I do that?

    Any help would be greatly appreciated.

Viewing 1 replies (of 1 total)
  • Thread Starter andrejcremoznik

    (@andrejcremoznik)

    Found out it was a problem with nginx conf. If someone else has problems with get requests, make sure there’s a rewrite block like this:

    location / {
            try_files $uri $uri/ @rewrites;
    }
    location @rewrites {
            rewrite ^ /index.php last;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Can't access custom query vars (permalinks & nginx)’ is closed to new replies.