WordPress.org

Support

Support » How-To and Troubleshooting » Rewrite custom wordpress url for posts

Rewrite custom wordpress url for posts

  • Hello,

    I want to do something very simple.. but i cant figure it out..
    I made separate page for the post comments, using this method and its working fine.
    Right now the comments url page looks like that:
    sitename.com/postname/?show=comments

    I want to rewrite this url to sitename.com/postname/comments

    The site working with mod_rewrite..

    I tried that:

    add_action( 'init', 'ss_permalinks' );
        function ss_permalinks() {
            add_rewrite_rule(
                'bestpro/comments',
                'index.php?p=11&show=comments',
                'top'
        );

    It’s worked but i need it to be full dynamic.
    In this example it’s working only on post id 11 (p=11) with the name bestpro
    How can i made it work dynamically and use something like %postname% ?

    I toke this code from different post which someone made.. so maybe this code not good for my purpose…

    Thanks for the help!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Rewrite custom wordpress url for posts’ is closed to new replies.