Re-directing URLs with dates to URLs without dates
You just have to set your permalinkstructure to /%postname%/. Special rewrite rules do not need to be done here, as this is a simple setting WordPress handles on it’s own.
You just have to set your permalinkstructure to /%postname%/. Special rewrite rules do not need to be done here, as this is a simple setting WordPress handles on it’s own.
You can filter page_link to modify the output of any page’s permalink value. The simplest way to identify the page is by ID, then you can append the query string via add_query_arg: function wpd_append_query_string( $url, $id ) { if( 42 == $id ) { $url = add_query_arg( ‘ngg_force_update’, 1, $url ); } return $url; } … Read more
The rewrite rule already exists to handle those requests, it’s for pagination of a single page post type. You can get the value of the page number with get_query_var(‘page’). You can render all pages with the same template by creating a page-{page-name}.php template file.
First, create a single states page. Add a query var to hold the state value, wpd_state: function wpd_query_vars( $qvars ) { $qvars[] = ‘wpd_state’; return $qvars; } add_filter( ‘query_vars’, ‘wpd_query_vars’ , 10, 1 ); Add a rewrite rule to capture the state from the URL, set the wpd_state query var, and load the page states: … Read more
I would argue this is micro-optimisation and your efforts will be better spent elsewhere – an extra 80 rules is a blink in the total WordPress runtime (they’re just a foreach loop with a preg_match). You are much better off making sure that any custom database tables are designed effectively, your queries are efficient, and … Read more
If you want to change your WordPress Address (URL) one option is to make use of this tool: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/ Just download it, upload it to your server, extract its files and access it via your browser. Example: Suppose your WordPress Address (URL) and your Site Address (URL) are “http://www.example.com” (without quotes obviously). So if you … Read more
All internal rules must point to index.php. This isn’t your theme’s index.php file, this is the main core WordPress bootstrap file. Rewrite rules set query vars, query vars get parsed into queries, those queries have template files associated with them depending on type. Internal rewrite rules never point directly to theme files. If you want … Read more
The root problem here is a misunderstanding of how URLs work. What you see in the browser is not a full URL, but something to make it easier to understand For example, take this URL: http://example.com/test/?foo=bar#bananas Here we have instructions to: Via HTTP protocol aka http:// contact the server at example.com aka https://example.com and do … Read more
The rewrite argument in register_post_type is limited, but you can define a more complex structure with add_permastruct. The added benefits are that this will generate all the rewrite rules for you, and the new rules will overwrite the originals. You just have to be sure to hook after the post type is registered. function wpd_woo_product_permastruct(){ … Read more
Rewrite rules in WordPress should point to index.php, and to substitute a matched value (number from address) to URL parameter (item_id) you must use $matches[1] instead of $1. So your rule should look like this: add_rewrite_rule(‘^add-item/([0-9]+)/?’, ‘index.php?item_id=$matches[1]’, ‘top’); You usually need to complete the rule with information about what is displayed. For display: single post … Read more