Finding and removing unnecessary redirects

While in the process of implementing a CSP and defining the allowed sources, I was shocked to find the total number of resources ShareThis calls. At the time of writing this, I counted a total of 39 domains and subdomains it uses. Not a big surprise anymore why ShareThis was causing my slow page load … Read more

Rewrite Url to a SEO-friendly format

The easiest way to do this is with the built-in $wp_rewrite global. Something like this should give you a good start: function new_rewrite_rules(){ global $wp_rewrite; $keytag = ‘%user_id%’; $wp_rewrite->add_rewrite_tag($keytag, ‘(.+?)’, ‘user=”); $structure = $wp_rewrite->root . “username-$keytag/”; $rewrite = $wp_rewrite->generate_rewrite_rules($structure); if(!is_array($wp_rewrite->rules)) $wp_rewrite->rules = array(); $wp_rewrite->rules = $rewrite + $wp_rewrite->rules; return $wp_rewrite->rules; } You would then access … Read more

Rewrite rules goes away

properties_add_rewrite_rules should be hooked to init so it runs on every request. Rules can be flushed at any time- loading the permalinks settings page calls flush_rewrite_rules, and your rules weren’t added on that request, so they disappear.

Custom taxonomy Rewrite Rule

You could use 2 of WordPress’ built in functions to get the result you’re after. add_rewrite_tag() and add_rewrite_rule() There is an example of how to use these tags to get the result you want about halfway down this page https://codex.wordpress.org/Rewrite_API/add_rewrite_rule. Note: remember to flush your rewrite rules.