How to Set Up A Custom Permalink Structure In WordPress?

13 minutes read

To set up a custom permalink structure in WordPress, you need to access the Permalinks settings in your WordPress admin area. Here's how:

  1. Log in to your WordPress admin area.
  2. Locate and click on "Settings" in the left-hand sidebar.
  3. A drop-down menu will appear. Click on "Permalinks."
  4. You will now see different options for the permalink structure. By default, WordPress uses the "Plain" option, which includes a post ID in the URL. However, you can create a custom structure by selecting one of the options below.
  5. If you want to create a custom structure, you can use tags to define how your URLs will look. For example, if you want your post URLs to include the post name, you can choose the "Post name" option.
  6. To further customize your structure, you can use specific tags. Here are a few commonly used tags: %postname%: The post slug or the post's URL-friendly version of the title. %post_id%: The unique numerical identifier of the post. %category%: The main category of the post. %year%: The year the post was published in. %monthnum%: The numerical representation of the month the post was published in.
  7. Once you have selected your desired permalink structure or created a custom one, scroll down and click on the "Save Changes" button to apply the changes.
  8. After saving the changes, your posts and pages will now have URLs based on your specified structure.


It's important to note that changing your permalink structure can affect the existing links on your website. If your site is already indexed by search engines or shared on other platforms, the old URLs may result in errors or broken links. To mitigate this, you can set up redirects from the old URLs to the new ones using plugins or manual configurations.

Best WordPress Books to Read in 2024

1
Building Web Apps with WordPress: WordPress as an Application Framework

Rating is 5 out of 5

Building Web Apps with WordPress: WordPress as an Application Framework

2
WordPress: The Missing Manual: The Book That Should Have Been in the Box

Rating is 4.9 out of 5

WordPress: The Missing Manual: The Book That Should Have Been in the Box

3
WordPress 5 Complete: Build beautiful and feature-rich websites from scratch, 7th Edition

Rating is 4.8 out of 5

WordPress 5 Complete: Build beautiful and feature-rich websites from scratch, 7th Edition

4
WordPress 5 Cookbook: Actionable solutions to common problems when building websites with WordPress

Rating is 4.7 out of 5

WordPress 5 Cookbook: Actionable solutions to common problems when building websites with WordPress

5
WordPress Plugin Development Cookbook: Explore the complete set of tools to craft powerful plugins that extend the world's most popular CMS, 3rd Edition

Rating is 4.6 out of 5

WordPress Plugin Development Cookbook: Explore the complete set of tools to craft powerful plugins that extend the world's most popular CMS, 3rd Edition

6
WordPress All-in-One For Dummies (For Dummies (Computer/Tech))

Rating is 4.5 out of 5

WordPress All-in-One For Dummies (For Dummies (Computer/Tech))

7
Professional WordPress: Design and Development

Rating is 4.4 out of 5

Professional WordPress: Design and Development

8
WordPress: Pushing the Limits

Rating is 4.3 out of 5

WordPress: Pushing the Limits


How to add custom variables to permalinks?

To add custom variables to permalinks in WordPress, you can follow these steps:

  1. Open your theme's functions.php file, which can be found in your WordPress theme's folder.
  2. Inside the functions.php file, add the following code snippet:
1
2
3
4
function custom_rewrite_tag() {
    add_rewrite_tag('%custom_variable%', '([^&]+)');
}
add_action('init', 'custom_rewrite_tag', 10, 0);


Replace %custom_variable% with the name of the custom variable you want to add to the permalinks.

  1. Save the functions.php file.
  2. Next, you need to flush the rewrite rules. This can be done by simply visiting the "Settings" -> "Permalinks" page in your WordPress admin dashboard and clicking the "Save Changes" button.
  3. Now you can use the custom variable in your permalinks. For example, if your custom variable is "author_name", you can use it in a permalink structure like this: /%year%/%monthnum%/%postname%/%author_name%/.


Remember to update the permalink structure in the "Settings" -> "Permalinks" page to include your custom variable.

  1. Finally, you can access the value of the custom variable in your template files using the get_query_var() function. For example:
1
$custom_variable_value = get_query_var('custom_variable');


Replace 'custom_variable' with the name of your custom variable.


That's it! Your custom variable should now be included in the permalinks and accessible in your template files.


How to make permalinks more SEO-friendly?

There are several ways to make permalinks more SEO-friendly:

  1. Use descriptive keywords: Include relevant keywords in the permalink that accurately describe the content of the page. This helps search engines understand what the page is about.
  2. Keep it concise: Try to keep permalinks short and concise while still conveying the page's content. Long, complicated URLs can be difficult for users to read and might not be seen as favorable by search engines.
  3. Use hyphens as separators: Instead of using underscores or spaces, use hyphens to separate words in the permalink. Search engines generally prefer hyphens as word separators.
  4. Exclude unnecessary words: Remove unnecessary words like "and," "the," "a," or "of" from the permalink to keep it focused on the main keywords and make it more concise.
  5. Avoid using dates: If possible, avoid including dates in the permalink unless it's relevant to the content. Date-specific URLs may appear outdated and can discourage users from clicking on them.
  6. Don't change permalinks frequently: Avoid changing permalinks once they are published. Changing permalinks frequently can lead to broken links and negatively impact SEO.
  7. Utilize proper URL structure: Make sure your permalinks follow a logical hierarchy or structure that reflects the content's organization on your website. This can improve user experience and help search engines understand the site's architecture better.
  8. Implement canonical URLs: Use canonical tags to indicate the preferred version of a page when there are multiple URLs with similar content. This helps avoid duplicate content issues and ensures search engines understand which URL to index.


Remember, the primary goal is to create permalinks that are descriptive, easy to read, and relevant to the page's content, providing value to both users and search engines.


What is a slug in permalink structure?

In the context of permalink structure, a slug is a part of a URL that identifies a specific page or post on a website. It typically appears after the domain name and any parent directories.


A slug is a user-friendly, human-readable string of words or characters that helps describe the content of the page. It is usually derived from the title of the page or post, with certain modifications such as removing special characters, converting spaces to dashes, and making all letters lowercase.


For example, in the URL "https://www.example.com/blog/my-post-slug", "my-post-slug" is the slug that uniquely identifies the specific blog post on the website.

Best WordPress Hosting Providers in 2024

1
DigitalOcean

Rating is 5 out of 5

DigitalOcean

2
AWS

Rating is 4.9 out of 5

AWS

3
Vultr

Rating is 4.8 out of 5

Vultr

4
Cloudways

Rating is 4.7 out of 5

Cloudways


What is the recommended permalink structure for a news website?

The recommended permalink structure for a news website typically includes the following elements:

  1. Post type: The post type should be included in the permalink to differentiate between different categories of content. For a news website, it is usually "news" or "article".
  2. Date: Including the publication date in the permalink can help with organizing and categorizing news articles. It is often represented as year, month, and day.
  3. Title: The title of the news article should be a part of the permalink. This helps create a clear, readable URL that reflects the content.


An example of a recommended permalink structure for a news website could be: /%post_type%/%year%/%monthnum%/%day%/%postname%/


Here's what the structure would look like for an article published on March 15, 2022, titled "New Study Reveals Insights on Climate Change": /news/2022/03/15/new-study-reveals-insights-on-climate-change


How to change the permalink structure in WordPress?

To change the permalink structure in WordPress, follow these steps:

  1. Log in to your WordPress admin panel.
  2. Go to the "Settings" tab and click on "Permalinks."
  3. You will see various permalink structure options. Choose the one that suits your needs or select "Custom Structure" to define your own structure.
  4. If you selected "Custom Structure," you can enter your desired permalink structure using specific tags. These tags represent different elements of your URLs, such as post name, post ID, category, and more. Here are a few examples of tags you can use: %postname%: The post slug or URL-friendly version of the post title. %post_id%: The unique ID assigned to each post. %category%: The category the post belongs to.
  5. Once you have set your desired permalink structure or custom structure, click on the "Save Changes" button at the bottom of the page.


After saving the changes, your WordPress site will start using the new permalink structure for all future posts and pages. However, keep in mind that changing the permalink structure can affect the existing permalinks of your published content. If you have an established website with existing content, it's important to set up proper redirects to ensure that old URLs are redirected to their new counterparts, thereby avoiding any broken or inaccessible links.

Facebook Twitter LinkedIn Telegram

Related Posts:

To create a custom login page in WordPress, you will need to follow these steps:Create a new PHP file: Start by creating a new PHP file for your custom login page. You can name it according to your preference, like "custom-login.php". Add the necessary...
Creating a custom WordPress theme allows you to have full control over the design and functionality of your website. Here are the steps involved in creating a custom WordPress theme:Set up a development environment: Install WordPress on your local computer usi...
To add a custom post type in WooCommerce, you can use the register_post_type function in WordPress. First, create a new PHP file in your theme or plugin directory to define your custom post type. Inside this file, use the register_post_type function provided b...