WordPress.org

Ready to get started?Download WordPress

Forums

Reserved words/params list? (11 posts)

  1. claco
    Member
    Posted 4 years ago #

    I have an otherwise working installation and am writing a new theme. I have friendly urls set to /%category%/%postname%/ and .htaccess setup. Everything works as I would expect, including links to pages, and pages with custom templates assigned.

    If I pass query string params in the url, they work just fine:

    /mypage/?foo=bar

    The minute I pass something like /mypage/?m=1, or ?year=2010, I get a 404 page instead. ?year=2009 returns the page.. ?year=2008 returns a 404.

    My htaccess is nothing more than:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /~claco/wordpress/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
    </IfModule>

    What's going on here? Is there a set of reserved query string param names that influence the loading of the pages content entry, which causes the 404?

    I'm thoroughly confused.

  2. iridiax
    Member
    Posted 4 years ago #

    Beware, the default permalinks always work (including date archives), even if you have pretty permalinks enabled.

  3. claco
    Member
    Posted 4 years ago #

    Which relates to my problem how?

  4. iridiax
    Member
    Posted 4 years ago #

    The minute I pass something like /mypage/?m=1, or ?year=2010, I get a 404 page instead.

    You are improperly using WordPress query strings with your pages. The WordPress reserved query strings can be seen in the default permalinks. As for the 2010 query giving a 404, I'd imagine that there isn't a 2010 WordPress archive yet since it's in the future.

    ?year=2009 and ?m=2009 both get you the 2009 WordPress archive. If you are using pretty permalinks, then /date/2009/ would get you the same thing.

  5. claco
    Member
    Posted 4 years ago #

    The problem is, a) I've found no definitive list of reserved query string params, and b) Magic is bad.

    I have a single page template, and I want to use various query string params in custom code to control the behavior of different elements on that page. It seems silly that I have to play a guessing games about how I can write PHP and pass query string elements (just like I would do in any other web framework in the world). Why m and not month? Why year and not y? Just because the wordpress urls are friendly, doesn't mean all use of the query string params for applications, plugis and custom code can't be used. And since my custom permalink style doesn't include %year%, it seems broken.

    Here's the real example. I have a template called vulunteer.php, tied to the Volunteer page. That template displays the pages content and all is well. Now I added a block of code to pull a set of unrelate information form the database, and that code was going to look for the year and month query params to determine what information they were interested in.

    Worked fine for ?year=2009&month=3. The minute year went to 2010, or 2008, I get a 404. The minute I change my code to use ?y=2010&m=3, I get a 404 because WordPress is in love with the m param.

    That's why I'm frustrated. I could understand if year is a reserved query string param, but then I would expect month to be reserved, not m.

    All in all, it's a big fail in terms of expectations.

  6. claco
    Member
    Posted 4 years ago #

    Also, using year/m to retrieve an archive on a Page (not a post, or a template for a category, multiple posts, etc) seems broken. It's a single entry for a single page. Year should be ignored.

  7. iridiax
    Member
    Posted 4 years ago #

    I've found no definitive list of reserved query string params

    I haven't either. There must be one somewhere, but I haven't been able to find it in the Codex or by Googling.

  8. pj_mfc
    Member
    Posted 4 years ago #

    I had a similar problem related to forms and $_POST. It took me almost an hour to figure out that my form data was not showing up in the $_POST because I had used name="name" and name="email" in my input tags. Changing the tags to use name="form_name" and name="form_email" allowed everything to post to the page properly. I did not find this in the documentation, only mentioned in a couple of blogs as a potential solution to form posting problems. It would be great to see this issue explained and documented in the official docs.

    I'm also curious to see if this function is related to this issue:

    http://codex.wordpress.org/Function_Reference/form_option

  9. Steve Taylor
    Member
    Posted 4 years ago #

    I just got this too, using "day" as a query string parameter. It would be nice to have a definitive list of reserved qs var names, but it's not a big stumbling block. It took me 2 seconds to find a name that worked :-)

  10. Bombdogs
    Member
    Posted 4 years ago #

    This is madness - there must be a list of reserved GET/POST params? I only found this thread after I sussed the behaviour myself.

    I'm using a Java plug-in which POSTs back to the page the vars a,i,k & m and the POST was obviously being greeted with the aforementioned 404.

    You can imagine how many blind alleys I went down and how long it took before I realised that it was the param 'm' causing the behaviour. It wasn't 2 seconds.

    Perhaps 'm' stands for magic. Or mental.

    PMF

  11. Simon Blackbourn
    Member
    Posted 3 years ago #

    There's a list in the Codex here, admittedly not very easy to find, I stumbled across it by pure chance, and also not complete ('m' is missing for example):

    http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms

    the definitive list is here if you look at the content of $public_query_vars and $private_query_vars:

    http://core.trac.wordpress.org/browser/trunk/wp-includes/classes.php

Topic Closed

This topic has been closed to new replies.

About this Topic