Support » Plugins » Can’t add extra query strings?

  • Hello, in one of my templates called profile.php (I’ve made a page which page_id is 14) I want to use query-strings to perform database searches.

    When I open the following address for instance:
    http://localhost/wp/?page_id=14&author=Testo
    I get a “Not Found” error from WP. If I remove the &author=Testo part it loads fine though.

    I’m making a profile page for each of the commenters, and I’d need to use the author_name (little website, so duplicate names aren’t an issue) as the identification.

    Any reasons why I can’t add extra arguments to my query string?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I would not use query keys WordPress already assigns internally. There’s the opportunity for conflicts when trying to use it for something else. This is true even if your intentions are to duplicate a process (i.e. authors).

    Beyond that, I assume you are somehow correctly processing the query value in a script used in the Page’s template?

    Thread Starter keikenti

    (@keikenti)

    Not even started to process the query values in the template I’ve created as making additions to the query string somehow messes up the page_id for some reason.

    The idea is to make a page that lists all the people who have left a comment (I call it hugs on my website) with some basic statistics.. If you select one of them you get an extended list.

    I guess the only way to do this without making my very own PHP script in the root folder is to just use CSS to hide the extended information and then use JS to show/hide.

    How much work is it to access WP information without using the template engine?

    In regards to the author query above not working as shown, you have two issues:

    • author takes the numeric user ID, whereas author_name is passed the login.
    • If you’re on a Page or post not created by the author you’re querying, there cannot be a match (hence the “not found” message).

    This is what I meant by “opportunity for conflicts.” You can’t pass a GET query and just expect it to work differently or override WordPress’ interpretation of it, which is to list an author’s posts (or in this case, Page).

    You can certainly do what you’re after here, but first you need to come up with your own GET query key (i.e. user, the_author, whatever) and build a script around it which captures the custom GET query, and if passed to the Page will process it and list just that user’s information.

    Note this does not have to be handled outside of ones theme; if setting up a Page for this you only need to create a Page template that includes the custom scripting:

    http://codex.wordpress.org/Pages#Page_Templates

    Thread Starter keikenti

    (@keikenti)

    Oh, don’t misunderstand by the way: I don’t allow people to sign up on my blog at the moment. Since people who comment have no other unique ID than their email address I’m forced to using their name.

    I guess the easiest way is like I stated in my previous post: no profile pages but use a show/hide link to display their extended info.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can’t add extra query strings?’ is closed to new replies.