Results 1 to 3 of 3

Thread: Rewrite rule

  1. #1
    Thread Starter
    Junior Member ablain's Avatar
    Join Date
    Nov 2012
    Location
    Canada
    Posts
    38
    Thanks
    6
    Thanked 5 Times in 4 Posts

    Rewrite rule

    Hello,

    I want to rewrite url and dont understand how to do it.

    I want people to be able to access www.mysite.com/author/username trough this url www.mysite.com/username

    Can someone help me do it?

    Thanks for your time!

  2. #2
    Member patrickjose's Avatar
    Join Date
    Dec 2012
    Location
    Brazil
    Posts
    83
    Thanks
    1
    Thanked 25 Times in 15 Posts
    This is very simple and I think AppThemes Team can put this feature on the new version.

    Open your functions.php file under the theme folder.

    At the end of file, before ?> add this:

    Code:
    // change author base permalink
    function change_author_permalinks() {
        global $wp_rewrite;
        $wp_rewrite->author_base = '';
        $wp_rewrite->author_structure = '/' . $wp_rewrite->author_base. '/%author%';
    }
    add_action('init','change_author_permalinks');
    Save the file and close.

    Now to go your WP Admin -> Settings -> Permalinks and just click on Save Changes and it's done.

    If you want something like www.mysite.com/advertiser/username just change:

    Code:
    $wp_rewrite->author_base = 'advertiser';
    That's all.

  3. #3
    Member patrickjose's Avatar
    Join Date
    Dec 2012
    Location
    Brazil
    Posts
    83
    Thanks
    1
    Thanked 25 Times in 15 Posts
    Well, my example above without author_base won't work...

    Actually will work for author's base but all the other links will be broken.

    You must have a prefix for it, like the second example -> $wp_rewrite->author_base = 'advertiser';

    If you don't want to do it manually, there is a plugin called [url=http://wordpress.org/extend/plugins/edit-author-slug/]Edit Author Slug[/code] which does the same thing but it have more implementations.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. One rule for one, and another for others?
    By manamaga in forum Report ClassiPress Bugs
    Replies: 3
    Last Post: October 29th, 2012, 08:39 AM
  2. What codes or rewrite rules do I need for Social Connect?
    By ecwalker in forum Report ClassiPress Bugs
    Replies: 2
    Last Post: September 2nd, 2012, 09:55 PM
  3. rewrite.script needed for multisite
    By gibbere in forum Report ClassiPress Bugs
    Replies: 1
    Last Post: March 16th, 2012, 07:25 PM
  4. Need help to over-ride a rule in red-black.css
    By swapmama in forum ClassiPress General Discussion
    Replies: 3
    Last Post: September 12th, 2011, 08:56 PM