Rewrite parameters as Url for SEO

Because it’s not enough to register your rule, you need to flush the rewrite rules for it to take effect. An easy way of doing this is to visit the permalinks settings page. This is true regardless of where the rewrite rule came from. The most common reason people encounter this is because of the … Read more

How to set add_query_arg properly for home page?

Is there a problem with the code? Your code is already properly adding the lang query variable to the homepage URL. But you need to understand these points: On the homepage URL becomes http://localhost/mywebsitename/?lang=en which should be ok $wp->request is empty on the homepage, hence the above URL is expected. And you could use get_queried_object()->post_name … Read more

How to pass username in affiliate link in wordpress website

This code adds the subid parameter if does not exist to the current URL. Use this plugin to insert the php code: https://wordpress.org/plugins/my-custom-functions/ But you need to use add_action() to call this function somewhere. function my_change_url() { global $wp; $current_url = home_url(add_query_arg(array($_GET), $wp->request)); if ( empty($_GET[‘subid’]) ) { $cuser = wp_get_current_user(); $username = $cuser->user_login; $current_url … Read more

Add static text to post URLs

if i good understand your problem, you should to go: Dashboard -> Settings -> Permalinks and in “Common Settings” section select checkbox “Custom Structure” and here paste: /my-blog/%postname%/ and save changes. Now refresh your page and go to random post and your url should be like: https://example.com/my-blog/this-is-the-article-name Good luck!