Add Rewrite Rule to point to a file on the server

(Revised answer) Don’t call flush_rewrite_rules() on init. Instead, if you want to do it programmatically, call the function from your plugin or theme activation function. If you’re not doing it programmatically, you could simply visit the Permalink Settings page (Settings → Permalinks on the WordPress back-end). WordPress does support adding a rewrite rule that doesn’t … Read more

Rewrite url for existing page without flush_rewrite_rules

If you want to rewrite example.com/test123 (a standard WordPress Page) to example.com/test234 (another standard WordPress Page) without having to save the rewrite rules in the database, then one option is using the request filter hook: add_filter( ‘request’, function ( $query_vars ) { if ( isset( $query_vars[‘pagename’] ) ) { $slug = $query_vars[‘pagename’]; // Define a … Read more

add_rewrite_rule() not working

You rewrite rule is quite broad and will most likely generate a lot of conflicts. add_action(‘init’, ‘dcc_rewrite_tags’); function dcc_rewrite_tags() { add_rewrite_tag(‘%propref%’, ‘([^&]+)’); } add_action(‘init’, ‘dcc_rewrite_rules’); function dcc_rewrite_rules() { add_rewrite_rule(‘^cottage-details/(.+)/?$’,’index.php?page_id=2&propref=$matches[1]’,’top’); } Then you can access to propref query var like: $propref = get_query_var( ‘propref’ ); And remember to flush the rewrite rules; you can do it … Read more

Custom Post Type rewrite redirects to homepage

The most important args for rewrite redirects when registering new post type are: ‘public’ => true, ‘publicly_queryable’ => true, ‘query_var’ => true, I have pasted some code below which I have tested and it working fine for the url : www.example.com/people/john $labels_employee = array(‘name’ => _x( ‘Employees’, ‘Post typegeneral name’, ‘textdomain’ ),’singular_name’ => _x( ‘Employee’, … Read more

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