How to change default permalinks for pages

WordPress gives you quite an amount of space to play around with permalinks. You can easily change how the link is shown in the address bar and if done correctly, different permalink structure can lead to better SEO and overall user experience.

By allowing you to use different structure tags, WordPress gives you the power to customize your URLs. But when you start customizing your permanent links, you’ll notice that your pages aren’t affected by different settings you try out.

Naturally, you will start scrolling down to find the same options dedicated to pages. Found one? No, you haven’t because WordPress doesn’t allow you to change the way pages are linked to your site. At least not from default settings page.

Customize permalinks structure for pages:

Fortunately, a simple function can help you to further customize your permalink structure:

  1. Open functions.php file
  2. Copy and paste the following code:
  3. function wploop_page_permalink() {
    global $wp_rewrite;
    $wp_rewrite->page_structure = $wp_rewrite->root . 'section/%pagename%/';
    }
    add_action( 'init', 'wploop_page_permalink' );
  4. Make changes to your page structure on the third line
  5. Save changes

If you’re following the same structure like in our example, your new URL leading to a page will get new part – “section”. Instead of www.yourdomain.com/thisispage, you will have to navigate to www.yourdomain.com/section/thisispage.

Following the example, it is easy to customize this. Change the “section” part to anything you want and try out few different permalinks to see which one suits you the best.

Permalinks for pages

If you rush to see your new URL and open any of the pages you have published, you’ll end up getting 404 error – that page cannot be found. This is just the last time WordPress tries to stop you from changing its pages permalink. But don’t be discouraged, you can still force your will onto the system.

If you thought you’re about to copy new function or install an additional plugin in order for this to work, don’t worry. WordPress only needs you to navigate to Settings -> Permalinks and hit “Save changes” button without actually making ones. This will tell WordPress about changes you’ve made in the functions.php and it will flush out its old permalink structure.

If you try to open any of the pages now, you will be happy to see that your page is open successfully and that permalinks have changed.

Similarly, you can change your author’s permalink structure.

If you made the changes, can you tell us what’s the reason behind customizing permalinks structure for pages?

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

One thought on “How to change default permalinks for pages

Leave a Reply

Your email address will not be published. Required fields are marked *