WordPress.org

Ready to get started?Download WordPress

Forums

Query Vars and Permalinks (2 posts)

  1. Arie Putranto
    Member
    Posted 1 year ago #

    Query vars which are PUBLIC will be used by WP_Query to determine what page should be displayed.

    Something like /?cat=1&author=1&year=2012 will show posts of category ID 1 written by author ID 1 on year 2012

    The same result should be achieve from /2012/?cat=1&author=1. But be aware of the second example, entering such URL will redirect you to /author/something/?cat=1 which I hate. Also entering /?cat=1&author=1 will break the page.

    From what I've been aware of, it because such URL will giving false positive where all conditions are meet. Take the first example, it will make all of the is_date(), is_author, and is_category() return true.

    THIS IS BAD! Why?

    First, WordPress behave strangely with this, and doesn't seem to have consistency on it. WP will redirect people to the proper URL if they enter the query string directly. Entering /?cat=1 for instance, will redirect to /category/uncategorized. What strange is, it doesn't act the same with /?post_format=image.

    Second, Archives are based on either category, tags, date, author, and now post_format. That what most people believe when design a template like me too. Thus, if you enter the URL on the first example, the loaded page is NOT a Date Archive, NOT an Author Archive, and NOT a Category Archive. It is a HOME, or Posts Page.

    How do you handle this is up to you. Me? I prefer to redirect people to Search Results page whenever they manually entered multiple query_string on URL. By doing this, I'm not breaking any archive page, and not confusing the visitor.

    Just my two cents

  2. Arie Putranto
    Member
    Posted 1 year ago #

    Check this: http://www.cleancode.co.nz/?cat=1&author=1 where it redirects to http://www.cleancode.co.nz/blog/author/zz?cat=1 where from the link we can judge that it is an Author Archive but the title displays that it is a Category Archive

Topic Closed

This topic has been closed to new replies.

About this Topic