Get WordPress username to customize url

You can only do that if the user is logged in (otherwise there is no “current” user). Depending on what your specific use case is, it would be something like this: if ( is_user_logged_in() ) { global $current_user; $current_user = wp_get_current_user(); // get the username: $username = $current_user->user_login; // set up the URL: $url = … Read more

Using a template file for a specific custom URL

I don’t know what nepal is (text prefix only or maybe taxonomy term), but it is not the most important thing, you will correct it if necessary. Rewrite rule like this should resolve the case. add_action( ‘init’, ‘se356109_events_custom_rule’ ); function se356109_events_custom_rule() { add_rewrite_rule( ‘nepal/events/(.+?)/([0-9\-]+)(:?/page/?([0-9]+))?/?$’, ‘index.php?events=$matches[1]&paged=$matches[3]’, ‘top’ ); } If you need to use URL date … Read more

WordPress inserting ?q= in URLs

Please make sure that you don’t have q as parameter in your permalink settings. You can see the permalink settings from wp-admin -> settings -> permalinks

Menu links URL with PHP GET method

Well. After a little search with the intention to find a way to re-use my category template (Sport), I found the solution of my problem: Force sub-categories to use the parent category template So I let this solution here in case of someone has the same problem and the same weird idea to resolve it … Read more