How to append an extension type to your page or post url in wordpress
-
At times the requirement may came or the client may want to add an page type extension to the wordpress auto generated page/post url. Mentioned below is the solution to add .html as extension to page or post url (However you can add any type of extension). The solutions worked for me so I expect this may also works for you.
Changing/Adding an extension to Post’s url.
Login to your wordpress admin
Access Settings > Permalinks
Choose Custom Structure and specify your structure. In my case i had choosed /%postname%.html (The forward slash ‘/’ after postname% been removed and .html had been added)Click on save changes. All that it will do is add .html to each and every post url that had been generated by wordpress.
Changing/Adding an extension to Page’s url.
Locate rewrite.php . You will found the page in wp-includes folder of your wordpress installation.
Replace the code from 1131 to 1143 line (locate function get_page_permastruct() function) with the following code
function get_page_permastruct() { if ( isset($this->page_structure) ) return $this->page_structure; if (empty($this->permalink_structure)) { $this->page_structure = ''; return false; } $this->page_structure = $this->root . '%pagename%'. '.html'; return $this->page_structure; }
Save the file and upload it. It will appeand an .html to each and every auto-generated url of wordpress page.
This solution may help you in achieving your goal.
- The topic ‘How to append an extension type to your page or post url in wordpress’ is closed to new replies.