• hi,
    I am wondering if there is any easy way to pass parameters to a template while still maintaining pretty urls and not running into a page not found error.

    As an example:
    if i have a userlist and want to create a page that filters by some criterias i can easily create a query based on the get parameters as long as i provide them in the usual form as ?parameter1=value1&parameter2=value2

    but as soon as i try to work with url rewriting and create sth like
    /parameter1/value1/parameter2/value2

    i will run into a 404 error as the page is not existing. So therefore it would be needed to handle this extra parameters internally with wordpress.

    is there any way to do this with native wordpress features? if so, how? can anyone point me into some direction.

    Thorsten

Viewing 6 replies - 1 through 6 (of 6 total)
  • modestobuzz

    (@modestobuzz)

    chyeaaa! I’d love to know how to do this too!

    I need this as well, and actually I don’t care too much about url rewrites for this particular page. &1=value1&p2=value2 is fine with me, but I can’t get that to work either?

    I have a search page and a results page that queries the database based on the input on the 1st search page

    I use custom template pages passing the parameters using $_get but keep getting an error (404) on https://www.domain.com/results.php?p=p1

    How, if at all can I do that?

    @vision22, did you manage to get it to work without the url rewrites?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    A plugin can do it. You might start here:

    https://codex.www.ads-software.com/Function_Reference/WP_Rewrite

    Thanks Otto, a good start and interesting stuff! although not a typical WP plugin but more a tutorial I think.

    I RTFM (also from sitepoint) ?? and still haven’t got a clue where to add what. I am aware of the .htaccess functionality, but I am not an expert. I do code php.

    Basically all I want is to include a page in my theme (or in the root) within WP that has parameters. Also, I do not mind the ugly URL’s for this specific function.

    So where does one add the $wp-rewrite code, and lets say I have a php page in my template called “results.php”, with 2 parameters (results.php?p1=a&p2=b) … is there a simple rule that tells WP that the page results.php (either in the root or in the theme dir) uses parameters and that it shouldn’t rewrite those?

    I added the following (and loads of variations):

    <?php
    $wp_rewrite->non_wp_rules = array( ‘/results/([0-9]+),([ad]*),([0-9]{0,3}),([0-9]*),([0-9]*$)’ => ‘/results.php?q=$1&l=$2’ );
    print_r($wp_rewrite->mod_rewrite_rules());
    ?>

    to results.php (and on various other locations, in the root, in the template directory, with path etc.) but to no avail. 404 galore ??

    thanks anyway for any input!

    Did anyone solve this? I think I have a similar problem…?

    it seems to be f****ed up in WordPress 2.6, the Feed Director plugin doesn’t work anymore…

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘pretty urls and extra parameters’ is closed to new replies.