WordPress.org

Ready to get started?Download WordPress

Forums

Need some help with add_rewrite_rule ! (3 posts)

  1. swissgecko
    Member
    Posted 2 years ago #

    Hi everybody,

    i'm searching long time the solution of this problem. i'm creating somme directories of society in internet, and i'm using wordpress. Here's my problem :

    in function.php file of my theme (created before with artisteer), i've add this code

    global $wp_rewrite;
    add_rewrite_rule('^annuaire/([^&]+)/?','index.php?p=5&ralias=$matches[1]','top');
    add_rewrite_tag('%ralias%','ralias=');
    $wp_rewrite->flush_rules();

    And it doesn't work.

    Finally, i have :

    http://mysite.com/annuaire/?ralias=society-name

    It's working and i can use "ralias" in my code ...

    And i want create one rule to rewrite like that

    http://mysite.com/annuaire/society-name/

    http://mysite.com/annuaire is a page ... with PHP code inside.

    Please, help me and tell me what is wrong in my code.

    Cheers from Switzerland !

  2. loughcorrib
    Member
    Posted 2 years ago #

    Would htaccess rewrite be an avenue for you

  3. Tekime
    Member
    Posted 1 year ago #

    I have had so many problems with add_rewrite_rule when implementing custom code/plugins I just started parsing the URL and taking over with template_redirect:

    http://gabrielharper.com/blog/2012/09/wordpress-custom-urls-for-plugins/

    Anyone else who's read five million posts about custom URLs might find it useful.. good luck :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.