Is your Blog page the one that’s set in the back end at Settings > Reading > Posts page
? If so, try checking for that in your first function:
/* Add .htm extension to Page URL Links */
add_action('init', 'htm_page_permalink', -1);
function htm_page_permalink() {
global $post;
if( get_option( 'page_for_posts' ) == $post->ID ) {
// don't add .htm to this page
return;
}
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.htm')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.htm';
}
}
The Option Reference pointed me at page_for_posts
.
Related Posts:
- Why does wordpress still strip my query var?
- Tricky URL rewrite with custom values in url
- Add a query string to ALL links on site
- Add rewrite rule for rewrite endpoint
- add_rewrite_rule not working for language specific characters
- How to add custom variable in url without redirect?
- How to building pretty URLs to reflect category hierarchy?
- Rewrite custom post type URL parameters
- Help with Rewrite Rule for Custom Post Type with Query String
- Change pagination url format
- Rewrite /category/cars into /topics/cars
- custom wordpress rewrite
- How to use wp rewrite to hide form action url?
- Dynamic URL with rewrite rule not working
- How do I rewrite URL that has custom parameter
- Pagination appearing twice in URL after rewrite
- URL Rewrite for CPT single posts
- Rename page URL
- WordPress post-type create url rewriting
- Does WordPress keep track of a post’s URL history and provide automatic redirects?
- Dynamic Endpoints
- How to add custom rewrite rule to .htaccess?
- Problem with add_rewrite_rule and pagination (paged and page query_vars)
- Rewrite url for custom post type
- add_query_vars and add_rewrite_rules
- When to call `add_rewrite_rule` for safety
- Rewrite rules goes away
- custom htaccess rewrite rule for page
- flexible rewrite ‘ramble’ URLs with WordPress
- add_rewrite_rule again
- Rewrite Rule for Post “Subpage”, with pagination
- Need to make a php file inside theme accessible via url
- Add_query_arg + two times the same argument?
- Rewrite loading custom template file but is_home() returns true, and there’s no 404
- Rewrite rule for admin-ajax.php
- add_rewrite_rule not registering on Multisite
- Change WordPress comments url / word
- Evaluating a external rewrite rule before internal wordpress rewrite rule
- How to check current URL for endpoint in a template file?
- How to Modify Existing Rewrite Rules?
- Custom rewrite rule
- Single Redirection Rule for Pages and Archive links
- Is it possible to remove feeds from rewrites?
- Define orderby in url
- Flush Rewrite Rules on init or rest_api_init?
- WordPress .htaccess – route other URLs to another app
- Rewrite URL – insert custom variables as a directory path
- How to properly rewrite url by custom var
- Can’t add external rewrites
- Changing RSS feed URL structure
- WordPress Rewrites – How can I pass a variable to Custom Post Type?
- Monkey Man Rewrite Analyzer says my rule will trigger but it doesn’t [closed]
- Need to add rewrite rule that adds in additional information about the post to url
- Front custom edit post page for each post
- add_rewrite_rule is redirecting instead of rewriting url
- Wildcard forward all posts and pages with few exceptions
- Create Dynamic SEO Friendly URL for Virtual Page
- add_rewrite_rule with query variables
- Rewrite rules automatically for pages using specific template
- Add language prefix to permalinks
- Custom Rewrite rule to captured post (rewrite rule to rewrite rule)
- How to redirect large amount of URLs?
- Help with rewrite rules for two post types
- How to pass url as a parameter in a add_rewrite_rule
- Customise particular RSS permalink
- RSS feed rewrite matching wrong rule
- Trouble with question mark in rewrite rule
- Removing “www” from a site URL
- Getting back a permalink from custom url
- What URL rewriting rule should I write to retrieve a var in the URL?
- Custom rewrite rule not working
- Weird characters behind every single link and images
- How can I allow trailing slashes on some URLs without a redirect, but not on others?
- Can’t use a specific custom URL (slug)?
- How do I get posts to appear at mydomain.com/blog?
- URL rewriting in wordpress using parameters
- Adding the amp url prefix to the beginning
- Custom route and extract data from slashes and parameter
- How to change search page url so that it still returns a page when there’s no search query specified?
- How to create dynamic URLs on WordPress?
- Rewrite Rules are Redirecting
- How to redirect to a login virtual page?
- Multiple permalink with and without category for same post
- Prefix only some posts with a custom prefix
- Help adding custom url, rewrite_rules_array
- Param causing 404
- How to use a capture from a rewrite rule inside a php file (like single.php)?
- url rewriting on custom post type
- Broken page redirect
- Get custom posts by segment of the URL
- Use Parent Pages for URL Structure without Landing Page
- add_rewrite Rule
- rewrite rule of post when accessed from archives pages
- How to create short urls for sharing and downloadable content?
- Rewrite rule is not working
- How to make a custom route with any-string-part/number-part pointing to an existing page?
- Post Type Rewrite Custom
- Help with url rewrite
- Remove url parameter using wordpress
- Wrong rewrite rules