I need to create a custom URL for all users to view user details.

My user information page URL is: https://www.example.com/author/test_user

I need to create a URL like this: https://www.example.com/test_user

Is it possible with WordPress?

  • (almost) everything is possible, what is the exact problem you have with implementing it yourself? – Mark Kaplun Aug 10 at 11:23
  • i don't know how to do this. Please guide me. – Rajnish Suvagiya Aug 10 at 11:52
  • In your opinion, how does WordPress will distinguish between post URL and user URL in case of example.com/test_user? – Max Yudin Aug 10 at 17:37
  • In WordPress there's an option to set your URL or permalink just go to your settings page, then check permalinks, choose the permalink style that you want. – rai nalasa Aug 10 at 23:38
up vote 0 down vote accepted

There is a simple solution for this. Add this code to your theme's functions.php. After that you need to re-save your permalinks from Settings->Permalinks in WordPress dashboard.

function remove_author_base() {
/**
 * Remove Author base from Wp Links
 * Serkan Algur
 */
    global $wp_rewrite;
    $wp_rewrite->author_base = '';
}
add_action('init', 'remove_author_base', 1);

I tested this code on my localhost (apache server with htaccess enabled). Please comment if code works or not.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.