• Resolved amasuriel

    (@amasuriel)


    I am new to wordpress development and am getting very frustrated with this.

    First, what I am trying to accomplish is this: I have a page template (and a published page) that has some form data (some dropdowns and a text field). I want to take these field values and query wp_usermeta to get a table with cetain meta_key / meta_value pairs…I am not using the info to get posts.

    First I had a terrible time figuring out how to pass parameters to the results page at all, since having a submit button appends the Submit x and y values etc to the post.

    Eventually after some trial and error and a lot of searching I found this: /www.rlmseo.com/blog

    I did this, and now I’m closer but not there yet.

    See adding a filter like add_filter('query_vars', 'add_query_vars'); in my functions.php (in my theme) did not add the variables returned in the add_query_vars method to query_vars, at least by the time it got to my templated pages.

    Adding add_filter('request', 'add_query_vars');got it to show up sortof in the template…but instead of getting a query_var with a key= to my vars in add_query_vars with a value of the rewritten querystring parameter (if it existed) I get a key=0, 1 etc with a value equal to the vars returned in add_query_vars.

    I hope that makes sense. I can post additional code if that would be helpful. Any insights would be great…I have spent way to long trying to get a simple search working.

Viewing 9 replies - 31 through 39 (of 39 total)
  • Thread Starter amasuriel

    (@amasuriel)

    wow duplicate post’a’thon. Sorry

    I think you’d be better of sticking with what you have already, you’d need a different set of rewrite rules and redirects to change the approach now..

    Going back to the issue with the 404.. think about it..

    Requesting ..

    example.com/advertisers/

    ..gives you the advertisers page right?

    example.com/advertisers/?province=example

    Should be treated no differently, as far as WordPress is concerned it’s still the advertisers page except there’s some query variables in the URL..

    There’s no reason i can see that you should have a 404 from such a request, and for what it’s worth that could be..

    example.com/advertisers/?a=1&b=2&c=3&d=4&e5

    ..or whatever else, that should be fine .. does the above give you a 404 to?

    Thread Starter amasuriel

    (@amasuriel)

    Wow, okay; how is this for bizarre.

    https://blogurl/advertisers/?province=testone&test2=test2 = 404 error
    https://blogurl/advertisers/?test1=testone&test2=test2 = works fine

    Is province a wordpress keyword or something?

    Thread Starter amasuriel

    (@amasuriel)

    You know what, I don’t even care why at this point. If I can get it to work by entering /?wtf=Ontario instead of /?province=Ontario I’m totally cool with that.

    You have been super helpful; if you are ever in the GTA (Toronto, Ontario) feel free to email me at
    #amasuriel
    at
    #hotmail.com
    without the hashmarks and I’ll buy you a beer (or 6).

    If i’m ever in that area of the world i’ll be sure to give a hola.. ??

    Regarding the problem currently, does the 404 still occur if you remove the query_vars filter (i’d hope not, but perhaps worth checking)..

    I don’t think it’s a reserved keyword else i’d see the problem to, maybe if you host has mod_security it’s flagging something in the request string, if you’re working locally that’s probably not the case.

    Perhaps swap the query var for something else if removing the filter made no difference..

    Thread Starter amasuriel

    (@amasuriel)

    Removing the filter does not fix it; and yes I’m working locally on a vanilla xampp install.

    I’ll just change it to serviceProv instead of province. Thanks again.

    Are you ok from here then? I assumed there was still more to be done, but if you’re happy and confident you’ve got what you wanted, that’s cool… ??

    Thread Starter amasuriel

    (@amasuriel)

    I have enough to move forward, so yeah I’m okay.

    ??

    Actually I am having a similar problem.

    I have set up the query vars and they work fine. For example https://mydomain/foo/?bar works, but https://mydomain/foo/bar does not. When I request https://mydomain/foo/bar i get redirected to https://mydomain/foo/, and my query vars has obviously been lost. ??

    How can I stop the redirecting from occurring?

Viewing 9 replies - 31 through 39 (of 39 total)
  • The topic ‘Problems adding to query_vars’ is closed to new replies.