Adding a query string to only one page url

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

Create a page that can be used for different URLs

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

Removing “www” from a site URL

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

show ALL latest posts with archive.php on example.com/latest

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

Trouble with question mark in rewrite rule

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

Insert post ID into the end of a slug preceeded by a dash

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

Integer based rewrite isn’t recognized for value of 1

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

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