rewriterule not working

Terminology I think you have some terminology a little mixed up: A URL “rewrite” alters the endpoint of a HTTP request. If http://example.com/param/exam1 really serves content from http://example.com/examples/exam1?get=param, then the former is being rewritten to the latter (though not necessarily visible to the end-user). In the world of URL-rewriting, a “redirect” is a rewrite that … Read more

Adding Rewrite URL for Base + Children Separately

Change your rewrite rules and the order to the following: add_rewrite_rule(‘my-url/([^/]*)/?$’, ‘index.php?my-var=$matches[1]’, ‘top’); add_rewrite_rule(‘my-url/?$’, ‘index.php?my-var=main’, ‘top’); Why the order? If the order would be the other way around, the first rule will always apply, so the ruleset would never reach your main page Why the changed syntax? To allow an additional query string to be … Read more

Username Variable in custom links?

The User data of the currently logged in user in WordPress can be retrieved via wpget_current_user() So you should be able to do something like this in your theme or wherever. $current_user = wp_get_current_user(); echo ‘<a href=”http://example.com/members/’ . $current_user->user_login . ‘/profile”>Your profile</a>.’; And build your link that way. HTH

WordPress custom permalink and archive link for custom post type

You need to either go into Settings -> Permalinks and click Save Or if you’re doing this programmatically you need to use flush_rewrite_rules(), but make sure this is only used when you activate/deactivate the plugin, DON’T set this in code that runs (like in init, or on every page load): https://developer.wordpress.org/reference/functions/flush_rewrite_rules/ register_deactivation_hook( __FILE__, ‘flush_rewrite_rules’ ); … Read more