Forum Replies Created

Viewing 15 replies - 1 through 15 (of 20 total)
  • Thread Starter amasuriel

    (@amasuriel)

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

    ??

    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.

    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).

    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)

    wow duplicate post’a’thon. Sorry

    Thread Starter amasuriel

    (@amasuriel)

    I understand what you mean. I’m not sure what is causing /advertisers/?province=example to 404…I had assumed that was standard wordpress behavior…like I said, I’m new on the platform ??

    So if there is something funky with the redirects causing it to 404 when it shouldn’t maybe I can take another approach.

    I discovered reading around today that I can make a normal php page “wordpress aware” by adding <?php include(‘wp-blog-header.php’); ?>, so maybe I should just make a straight php page that just spits out the results I want and I can use AJAX to make the call and populate the results inside the /advertisers page.

    Will that work? There isn’t anything weird with Ajax requests or calling a php page directly with something like searchservices.php?province=British+Columbia this in WordPress is there?

    Thread Starter amasuriel

    (@amasuriel)

    Ah but if I send /advertisers/?province=example&city=example&serviceField=example I get a 404 error.

    Or we still need to do one more redirect to make that work?

    Edit: The URL style is trivial to change, so consider it done already.

    Thread Starter amasuriel

    (@amasuriel)

    Okay, so the part I’m still missing then is some additional redirection.

    If you can help me with that I would appreciate it; I hope you like beer because I owe you a lot of it ??

    /advertisers is both the form and the results; it has some inputs for criteria an a PHP include before the footer that will take the paramaters (once I manage to pass them) and build a results table after some DB queries.

    The search button on the form will just redirect to the /advertisers page again with the optional parameters added to the URL on the fly with some javascript.

    Thread Starter amasuriel

    (@amasuriel)

    Yes.

    So the permalink for this page is /advertisers.

    /advertisers needs to be passed parameters so it can build a table of results; which I understood was done doing rewrite rules and a format like /advertisers/param1/param2/param3

    but when I request /advertisers/param1/param2/param3 the final URL I see is /advertisers. This makes sense to me since the rewrite rules we are both using (you are still using the rewrite rules in the test right?) convert /advertisers/param1/param2/param3 to /advertisers&paramname=param1 etc internally…how can you be getting /advertisers/param1/param2/param3 as the final URL if the rewrite rules are enabled?

    Thanks again for all your help, I know this is taking a lot of your time.

    Thread Starter amasuriel

    (@amasuriel)

    Ah so maybe this is the issue then.

    If I request url/advertisers/a/b/c/
    in the end I get url/advertisers…which given that that permalink for the page is url/advertisers makes sense does it not?

    How does it know what the permalink is from url/advertisers/a/b/c/?

    Edit: my permalink structure is set to /%category%/%postname%.

    Thread Starter amasuriel

    (@amasuriel)

    Sorry I had a meeting.

    Yes you will still get the page, but will the below work for you where /a/ is added to query_vars as province?

    <?php
    /*
    Template Name: test
    Description: blah
    */
    get_header();
    
    global wp_query;
    echo wp_query->query_vars['province'];
    
    get_footer();

    Also is the final URL you see when the page comes up after browsing to https://blogurl/advertisers/a/b/c = https://blogurl/advertisers/a/b/c or https://blogurl/advertisers?

    Thread Starter amasuriel

    (@amasuriel)

    Just that you can access the added query_vars (like province) from the template.

    Thread Starter amasuriel

    (@amasuriel)

    Yes.

    More importantly redirected to blogurl/advertisers without my parameters in query_vars.

    To reproduce just make whatever test /advertisers page you set up from before a Page and try to process the query_vars in the page template.

    If you attach a debugger and set a breakpoint in wp-blog-header.php you will see it gets processed twice; once the query_vars are set (after it does the rewrite from blogurl/advertisers/province/city/service), the second time they wont be.

    Edit: I mean it gets processed twice when you request blogurl/advertisers/province/city/service once

    Thread Starter amasuriel

    (@amasuriel)

    I’m 100% sure the template is the problem after my investigation this morning.

    The flow is:
    Called https://blogurl/advertisers/province/city/service
    I follow the code through index.php, which basically just includes wp-blog-header.php.

    wp-blog-header.php looks like:` $wp_did_header = true;

    require_once( dirname(__FILE__) . ‘/wp-load.php’ );
    wp();
    require_once( ABSPATH . WPINC . ‘/template-loader.php’ );`

    The wp() function is what parses the rewrite rules. At the end of this call my query_vars are set correctly.

    Then as you can see it calls template-loader.php. This first this template-loader.php does is call do_action(‘template_redirect’)

    In the do_action(‘template_redirect’) is part of plugin.php. It does this:

    do {
    		foreach ( (array) current($wp_filter[$tag]) as $the_ )
    			if ( !is_null($the_['function']) )
    				call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    
    	} while ( next($wp_filter[$tag]) !== false );

    And one of the filters that it calls redirect_canonical in canonicals.php, which as I mentioned finds the permalink URL for whatever its passed and redirects to it…which calls index.php again, only this time the URL is just https://blogurl/advertisers.

    I’m sure you will be able to reproduce if you try to use a Page with a template.

    Thread Starter amasuriel

    (@amasuriel)

    So the do_action(‘template_redirect’) eventually calls canonical.php, which attempt to figure out the permalink and redirects to it (losing all my parameters in the process; yay).

    I don’t really feel comfortable mucking about in the core wordpress page loading code; I feel like its likely I would inadvertently break something else if I did.

    Anyone have any idea how I can get around this? I assume it must be possible, as surely others have permalinked pages they pass values to.

Viewing 15 replies - 1 through 15 (of 20 total)