WordPress.org

Ready to get started?Download WordPress

Forums

pretty urls and extra parameters (7 posts)

  1. vision22
    Member
    Posted 6 years ago #

    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

  2. modestobuzz
    Member
    Posted 6 years ago #

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

  3. van Weerd
    Member
    Posted 6 years ago #

    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 http://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?

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    A plugin can do it. You might start here:

    http://codex.wordpress.org/Function_Reference/WP_Rewrite

  5. van Weerd
    Member
    Posted 6 years ago #

    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!

  6. loothi
    Member
    Posted 6 years ago #

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

  7. devil1591
    Member
    Posted 5 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic