Two Rewrite Rules

Catch those requests before WordPress can see them: RewriteEngine On RewriteBase / RewriteRule ^link/(\d+)$ /links/index.php?link=$1 [L,QSA] Place the WordPress rules below the link rules.

Rewrite function

Go to Settings->Permalinks Add this to Custom Structure: /%postname%/ Update WordPress generates .htaccess-files for this. Just go to your root and activate the show invisable files on your computer. Here is the htaccess for the structure: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d … Read more

URL Variables in a Certain Page

Try this code: add_filter( ‘query_vars’, ‘my_query_vars’ ); function my_query_vars( $vars ) { $vars[] = ‘catname’; return $vars; } add_action( ‘generate_rewrite_rules’, ‘my_rewrite_rules’ ); function my_rewrite_rules( $wp_rewrite ) { $products_page_id = 1; //your product’s page ID $wp_rewrite->rules = array( ‘products/?([0-9]{1,})/?$’ => $wp_rewrite->index . ‘?page_id=’.$products_page_id.’&paged=’ . $wp_rewrite->preg_index( 1 ), ‘products/(.+?)/?([0-9]{1,})/?$’ => $wp_rewrite->index . ‘?page_id=’.$products_page_id.’&catname=”.$wp_rewrite->preg_index( 1 ).”&paged=’ . $wp_rewrite->preg_index( … Read more

Rewrite URL variable to custom path

You could add the path via add_rewrite_endpoint, then alter the query via the pre_get_posts action. Here’s a proof-of-concept example that alters the posts_per_page when domain.com/highest-rated/ is requested: // add the endpoint function wpa85664_add_endpoint(){ add_rewrite_endpoint( ‘highest-rated’, EP_ALL ); } add_action( ‘init’, ‘wpa85664_add_endpoint’ ); // check if the endpoint is in the current request // and alter … Read more

URL Redirect in WordPress

For this kind of rewriting, I’m using this code (haven’t tested this one exactly, so may contain minor bugs): add_filter( ‘query_vars’, ‘binda_query_vars’ ); function binda_query_vars( $vars ) { $vars[] = ‘pp’; return $vars; } add_action( ‘generate_rewrite_rules’, ‘binda_rewrite_rules’ ); function binda_rewrite_rules( $wp_rewrite ) { $wp_rewrite->rules = array( ‘news/([0-9]{1,})/([0-9]{1,})/?$’ => $wp_rewrite->index . ‘?post_type=news’ . ‘&pp=’ . $wp_rewrite->preg_index( … Read more

Need Help With A Rewrite Issue

You could do something like this to rewrite rules for author titles, check out the monkeyman rewrite analyzer to figure out, following code should be in your functions.php add_filter(‘rewrite_rules_array’, ‘my_insert_rewrite_rules’); function my_insert_rewrite_rules($rules) { // Implement this function to add all the new rules to $rules array passed in $newrules = array(); $authors=get_users();//http://codex.wordpress.org/Function_Reference/get_users foreach($authors as $author) … Read more

Custom Rewrite Problem

You can try these rules: reviews/([^/]+)/page/?([0-9]{1,})/?$ reviews/([^/]+)/?$ It’s informative to check out the active rewrite rules with: function show_rewrite_rules( $rules ) { if(is_admin()) echo “<pre>”.print_r($rules,true).”</pre>”; return $rules; } add_filter(‘rewrite_rules_array’,’show_rewrite_rules’); and then visit /wp-admin/options-permalink.php. There exists also some good plugins for analysing the rewrite rules, for example the Monkeyman Rewrite Analyzer.

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