change default ‘post’ slug with register_post_type_args
change default ‘post’ slug with register_post_type_args
change default ‘post’ slug with register_post_type_args
rewrite_rule for custom post type doesn’t affect get_permalink
Add parent/child taxonomy to custom post type url
Custom URL rewrite to specific page template
Home page with Polylang redirects to other page [closed]
In order to add a parameter to all url of WordPress add_rewrite_endpoint() is more appropriate. I needed to add /foo after all URL so add_rewrite_endpoint(“foo”, EP_ALL); did the trick.
I think you can create a rewrite rule for each “region” to don’t overwrite other important rules you could need (like pages, categories, etc..). I was playing with your code examples and with a small change in rewrite_resets could work: public function rewrite_resets() { global $wp_rewrite; foreach($this->ENABLED_POST_TYPES as $post_type) { $args = get_post_type_object($post_type); switch($post_type) { … Read more
Thanks to Milo’s help the code in the question ended up working: permalinks fixed and the structure stayed exactly how I wanted it described in the question above. Removed the rewrite_rules_array hook entirely Moved my taxonomy registration above my post type registration Changed the taxonomy to be non-hierarchical ‘hierarchical’ => false From my limited understand … Read more
Hm. Have you thought about doing some URL rewrites in .htaccess? RewriteRule ^category/bar-talk/page/([0-9]+)$ /bar-talk/drink-number/$1 [L,R=301] RewriteRule ^bar-talk/drink-number/([0-9]+)$ /index.php?category_name=bar-talk&page=$1 [L] // @drizzlyowl
You could force the redirect this way by checking for the get_var query value: add_action(‘init’,’my_redirect_check’); function my_redirect_check() { if (isset($_GET[‘my_var’])) { if ($_GET[‘my_var’] != ”) { if ($_SERVER[“HTTPS”]) {$location = ‘https://’;} else {$location = ‘http://’;} $location .= $_SERVER[‘SERVER_NAME’]; $location .= strtok($_SERVER[‘REQUEST_URI’],’?’); $location = trailingslashit($location); $location .= $_GET[‘my_var’]; $location = trailingslashit($location); wp_redirect($location); exit; } } } … Read more