Changing Author Homepage URL Properly in WordPress

3 thoughts on “Changing Author Homepage URL Properly in WordPress”

  1. Flushing the rewrite rules is an expensive operation, executing it on the init hook is a bad practice. Flushing rules only should be run on plugin activation or deactivation.

    1. Thanks for your comment, Tareq. To be honest, if we both speak benchmarks, soft flush using $wp_rewrite->flush_rules() is not that expensive. One hundred soft flush call takes like 0.00078201293945312 seconds. And surprisingly, 100 get_the_category_list() takes 45 times more than that, 0.035834074020386 seconds in total. So you can see that a single get_the_category_list() call, which is pretty common and frequently used, is actually 45 times more expensive than a soft flush.

      Now I agree that this should be done from a plugin, precisely from the plugins_loaded or register_activation_hook and hard flushing would be best, but for the demonstration purpose of the whole thing to show how it works, it’s not bad attaching it in the init hook.

      And when it comes about cost, I totally don’t agree that a soft flush is expensive. It’s not. Not at all 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s