WordPress.org

Ready to get started?Download WordPress

Forums

Rewrite custom wordpress url for posts (2 posts)

  1. uplinkk
    Member
    Posted 2 years ago #

    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!

  2. uplinkk
    Member
    Posted 2 years ago #

    Anyone ?!
    Help please...

Topic Closed

This topic has been closed to new replies.

About this Topic