How to change the category and post prefix/slug to be the same in WordPress?
How to change the category and post prefix/slug to be the same in WordPress?
How to change the category and post prefix/slug to be the same in WordPress?
How to Stop WordPress Change Slug Automatically Same as Title When Publish?
Best way to approach creating a sitemap with unique URLS (No Permalink Changes)
Custom post permalinks for specific categories
Here’s how I did to fix it. Added this to my functions.php $url = $_SERVER[‘SERVER_NAME’].$_SERVER[‘REQUEST_URI’]; if($_SERVER[‘HTTPS’]){ $url=”https://”.$url; }else{ $url=”http://”.$url; } $id = url_to_postid( $url ); $url = parse_url($url,PHP_URL_PATH); $canonical = parse_url(wp_get_canonical_url($id),PHP_URL_PATH); if($url != $canonical){ wp_redirect(wp_get_canonical_url($id),302); } Basically if I hit an url that is not its own canonical, force a redirect. @Tom J Nowell, weird … Read more
No route was found that is identical to the URL and request method
WP Category Archive /page/2+ pagination issue 404
Permalinks and redirects
I think you can achieve the desired functionality by selectively adding the .html extension to specific pages using a custom rewrite rule and the page_link filter. // Add a custom rewrite rule to handle pages with .html extension function custom_html_page_rewrite_rule() { add_rewrite_rule( ‘^([^/]+)(\.html)/?$’, ‘index.php?pagename=$matches[1]’, ‘top’ ); } add_action(‘init’, ‘custom_html_page_rewrite_rule’, 10); // Filter page links to … Read more
To remove parent slugs from child pages’ permalinks in WordPress and avoid the 404 error, you’ll need to modify your code and add some rewrite rules. First, modify your code to remove the parent slug from the child page’s permalink: function my_pages_permalink($link, $post) { if ($post->post_parent) { $parent = get_post($post->post_parent); $link = trailingslashit(home_url($parent->post_name)) . $post->post_name … Read more