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

Custom rewrite rule not working

Hope this will work out for as it did for me. add_filter(‘rewrite_rules_array’, ‘insert_custom_rules’); add_filter(‘query_vars’, ‘insert_custom_vars’); function insert_custom_vars($vars){ $vars[] = ‘main_page’; return $vars; } function insert_custom_rules($rules) { $newrules = array(); $newrules=array( ‘page-name/(.+)/?’ => ‘index.php?pagename=page-name&main_page=$matches[1]’ ); return $newrules + $rules; } So, with the help of get_query_var() function, we can get value from url and use accordingly. … Read more

How would I get WordPress to parse /mypage/area/value as /mypage/?area=value?

add_rewrite_rule is very handy for this use, first add your custom rule for this: add_action(‘init’, function(){ return add_rewrite_rule( ‘([^/]+)/area/([^/]+)/?$’, ‘index.php?pagename=$matches[1]&area=$matches[2]’, ‘top’ ); }); and you already registered the custom query variable, next is (because you’re in development) go to admin > settings > permalinks and save settings to flush the rewrite rules. Now to get … Read more

WordPress simple Url Rewrite

Theme’s functions.php is not the best place to do these sort of URL rewrites. Why?: because in that case WordPress will be fully loaded and then redirected to a new link and then fully loaded again to show the page. That’s a lot of delay for a page view. Instead of that, you may use … Read more

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