username in rewritten URL, howto use it in a template

I created a new function, with which i get the username. Is there any problem with using it? Or is there a cleaner way of doing it? function getmyuser() { $test = substr($_SERVER[“REQUEST_URI”], strrpos($_SERVER[“REQUEST_URI”],”/user/”)+6); return str_replace(“https://wordpress.stackexchange.com/”,”, $test); }

how rewrite is working in wordpress

You can best analyse the URL rewrites with the URL Rewrite Analyser which has been developed by Jan Fabry, see the following answer for more information. Furthermore you can change the structure of the permalinks under the Options –> Permalinks of the WordPress admin section.

Rewriting WordPress URLs

The first important difference between your rewrite rule, and the ones that Pippin has provided is that all of his rewrite rules point to index.php. This is an absolute must, you won’t get it to work any other way, all requests must point to index.php with your query vars appended. The second important thing to … Read more

URL Rewriting in WordPress

Your best bet for an easy solution is to actually use the “Custom Structure” option in your WordPress admin under Settings > Permalinks. There are a number of other structure tags you may use as seen in the Codex. If you’re looking for even more customization and manual control, it’s actually a pretty complex topic … Read more

Additional .htaccess rules based on wp page

I’m pretty sure you have wrong “rewrite” parameter in your add_rewrite_rule call. I’m writing it directly in here, so it can be buggy… But it should look something like this: add_rewrite_rule(‘^authors/([^/]*)/([^/]*)/?’,’index.php?page_id=<YOUR AUTHOR PAGE ID>&my_author_name=$matches[1]&my_author_pic=$matches[2]’,’top’); Then you can use add_rewrite_tag (http://codex.wordpress.org/Rewrite_API/add_rewrite_tag) to add your custom query variables (my_author_name and my_author_pic). And in your author page you … Read more

Pagination posts. Url format

Your rewrite rule format is not correct. The $rewrite argument must point to index.php with query vars set so WordPress can create the default query: add_action( ‘init’, ‘wpa103850_init’ ); function wpa103850_init() { add_rewrite_rule( ‘^([^/]+)([0-9]{1,2}).htm$’, ‘index.php?name=$matches[1]&page=$matches[2]’, ‘top’ ); } However, this will still not work correctly, due to the canonical redirect. WordPress wants to enforce a … Read more

Getting URL Variables with a Rewritten Page (Login Page)

If you want instead of redirect to wp-login the user redirect to login page then use the following code. It will redirect user to login page where login form is present. add_filter(‘site_url’, ‘wplogin_filter’, 10, 3); function wplogin_filter( $url, $path, $orig_scheme ){ $old = array( “/(wp-login\.php)/”); $new = array( “login/”); return preg_replace( $old, $new, $url, 1); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)