WordPress.org

Ready to get started?Download WordPress

Forums

adding addtional rewriterule rules (3 posts)

  1. mrwok
    Member
    Posted 8 years ago #

    Alright, I'm having trouble understanding the rewrite rules generated by wordpress 2.0

    http://mywebsite.com/photos/Barcelona/1/

    Now WP is installed in the base directory. photos is a page created from wordpress, that has a template page that calls a script.

    The script looks for other variables, album and pg

    index.php?pagename=photos&album=barcelona&pg=1

    This use to work for me in wordpress 1.5
    RewriteRule ^(photos)/(.+)/([0-9]{1,})/?$ index.php?pagename=$1&album=$2&pg=$3 [QSA,L]

    There are now some extra rules that end up taking me to my "Sorry, no posts matched your criteria." page

    Any ideas?

  2. Austin Matzko
    Member
    Posted 8 years ago #

    Try putting something like this in a file named functions.php in your theme folder:

    function photos_filter($rules) {
    $rules['(photos)/(.+)/([0-9]{1,})/?$'] = 'index.php?pagename=$1&album=$2&pg=$3';
    return $rules;
    }
    add_filter('rewrite_rules_array', 'photos_filter');

    It uses one of the internal WP 2.0 rewrite rules hooks to add the rule. Your mileage may vary.

  3. mrwok
    Member
    Posted 8 years ago #

    Thank you very much, you are pimp

Topic Closed

This topic has been closed to new replies.

About this Topic