Bird
Raised Fist0
Wordpressframework~10 mins

Permalink structure in Wordpress - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Concept Flow - Permalink structure
User sets permalink format
WordPress saves permalink setting
User visits a URL
WordPress parses URL
Match URL to content type
Load and display content
Show page with friendly URL
This flow shows how WordPress uses the permalink structure set by the user to parse URLs and display the correct content with friendly URLs.
Execution Sample
Wordpress
1. User sets permalink to '/%postname%/'
2. User visits 'example.com/my-post/'
3. WordPress parses 'my-post'
4. Finds post with slug 'my-post'
5. Displays the post content
This example shows how a permalink with post name is used to find and display the correct post.
Execution Table
StepActionInput/StateResult/Output
1Set permalink structureUser selects '/%postname%/'Permalink saved in settings
2User visits URLURL: example.com/my-post/URL received by WordPress
3Parse URLExtract 'my-post' from URLSlug identified as 'my-post'
4Query contentSearch post with slug 'my-post'Post found in database
5Display contentPost data loadedPost page shown with friendly URL
6EndAll steps donePage rendered successfully
💡 Execution stops after content is displayed for the matched permalink URL.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
permalink_structuredefault/%postname%//%postname%//%postname%//%postname%/
requested_urlnoneexample.com/my-post/example.com/my-post/example.com/my-post/example.com/my-post/
slugnonenonemy-postmy-postmy-post
post_foundfalsefalsefalsetruetrue
Key Moments - 2 Insights
Why does WordPress need to parse the URL after setting the permalink?
Because the permalink structure defines how URLs look, WordPress must parse the URL to find the correct content. See execution_table step 3 where the slug is extracted from the URL.
What happens if the slug in the URL does not match any post?
WordPress will not find content and usually shows a 404 error. This is implied after step 4 if 'post_found' is false in variable_tracker.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3. What is the slug extracted from the URL?
A"postname"
B"my-post"
C"example.com"
D"/%postname%/"
💡 Hint
Check the 'Result/Output' column at step 3 in the execution_table.
At which step does WordPress find the post in the database?
AStep 4
BStep 3
CStep 2
DStep 5
💡 Hint
Look at the 'Action' and 'Result/Output' columns in the execution_table.
If the permalink structure changed to '/%year%/%postname%/', what would change in the variable_tracker?
AThe slug variable would include the year
BThe requested_url would no longer be 'example.com/my-post/'
CThe permalink_structure variable would update to '/%year%/%postname%/'
DThe post_found variable would become false
💡 Hint
Check the 'permalink_structure' row in variable_tracker for changes.
Concept Snapshot
Permalink structure in WordPress defines how URLs look.
User sets a format like '/%postname%/'.
WordPress parses URLs to find content by matching parts like post slug.
This makes URLs user-friendly and SEO-friendly.
Changing permalink affects URL parsing and content lookup.
Full Transcript
In WordPress, the permalink structure controls how URLs appear for posts and pages. When a user sets a permalink format, WordPress saves this setting. When someone visits a URL, WordPress parses the URL according to the permalink structure to extract key parts like the post slug. It then searches the database for content matching that slug. If found, WordPress loads and displays the content with the friendly URL. This process helps make URLs readable and meaningful. If the URL does not match any content, WordPress shows a 404 error. Changing the permalink structure changes how URLs are parsed and matched to content.

Practice

(1/5)
1. What does the %postname% tag represent in a WordPress permalink structure?
easy
A. The date the post was published
B. The slug of the post or page
C. The category of the post
D. The author of the post

Solution

  1. Step 1: Understand the purpose of %postname%

    The %postname% tag is used to insert the post slug, which is a URL-friendly version of the post title.
  2. Step 2: Compare with other tags

    Other tags like %year% or %category% represent date or category, not the post slug.
  3. Final Answer:

    The slug of the post or page -> Option B
  4. Quick Check:

    %postname% = post slug [OK]
Hint: Remember postname means the post's URL-friendly title [OK]
Common Mistakes:
  • Confusing %postname% with %category%
  • Thinking %postname% shows the date
  • Assuming %postname% is the author name
2. Which of the following is a valid custom permalink structure in WordPress?
easy
A. /%day%/%month%/%slug%/
B. /post/%author%/%date%/
C. /%year%/%monthnum%/%postname%/
D. /%category%/%postid%/%title%/

Solution

  1. Step 1: Check valid WordPress tags

    WordPress supports tags like %year%, %monthnum%, and %postname%. /%year%/%monthnum%/%postname%/ uses only valid tags.
  2. Step 2: Identify invalid tags in other options

    Options A, B, and C use invalid tags like %date%, %title%, or %slug% which are not recognized by WordPress.
  3. Final Answer:

    /%year%/%monthnum%/%postname%/ -> Option C
  4. Quick Check:

    Valid tags only = /%year%/%monthnum%/%postname%/ [OK]
Hint: Use only official WordPress tags in permalinks [OK]
Common Mistakes:
  • Using tags like %title% or %slug% which don't exist
  • Mixing date formats incorrectly
  • Forgetting trailing slash in structure
3. Given the permalink structure /%category%/%postname%/, what would be the URL for a post titled "Summer Tips" in the "Travel" category?
medium
A. /travel/summer-tips/
B. /summer-tips/travel/
C. /category/travel/summer-tips/
D. /travel/category/summer-tips/

Solution

  1. Step 1: Understand the structure tags

    The structure /%category%/%postname%/ means the URL starts with the category slug, then the post slug.
  2. Step 2: Apply to given post and category

    Category "Travel" becomes "travel" and post "Summer Tips" becomes "summer-tips". So URL is /travel/summer-tips/.
  3. Final Answer:

    /travel/summer-tips/ -> Option A
  4. Quick Check:

    Category + postname = /travel/summer-tips/ [OK]
Hint: Category comes first, then postname in this structure [OK]
Common Mistakes:
  • Swapping category and postname order
  • Adding extra words like 'category' in URL
  • Using capital letters in URL slugs
4. A WordPress site uses the permalink structure /%year%/%postname%/. After changing it to /%postname%/, some old links show 404 errors. What is the likely cause?
medium
A. The .htaccess file was not updated to reflect the new structure
B. The post slugs were deleted accidentally
C. The site URL was changed in settings
D. The category base was not set correctly

Solution

  1. Step 1: Understand permalink changes effect

    Changing permalink structure requires updating rewrite rules in the .htaccess file for URLs to work correctly.
  2. Step 2: Identify cause of 404 errors

    If .htaccess is not updated, old URLs won't redirect properly, causing 404 errors.
  3. Final Answer:

    The .htaccess file was not updated to reflect the new structure -> Option A
  4. Quick Check:

    Rewrite rules update needed = The .htaccess file was not updated to reflect the new structure [OK]
Hint: Always update .htaccess after changing permalinks [OK]
Common Mistakes:
  • Assuming post slugs were deleted
  • Ignoring .htaccess rewrite rules
  • Confusing category base with permalink structure
5. You want your WordPress URLs to show the year, category, and post name, but avoid duplicate URLs for posts in multiple categories. Which permalink structure helps prevent duplicates?
hard
A. /%year%/%category%/%postname%/
B. /%category%/%postname%/
C. /%postname%/
D. /%year%/%postname%/

Solution

  1. Step 1: Understand duplicate URL issue

    Using %category% can cause multiple URLs if a post belongs to multiple categories.
  2. Step 2: Choose structure avoiding category

    Removing %category% from the URL avoids duplicates. Including %year% and %postname% keeps URLs informative.
  3. Final Answer:

    /%year%/%postname%/ -> Option D
  4. Quick Check:

    Exclude category to prevent duplicates = /%year%/%postname%/ [OK]
Hint: Avoid %category% in URLs to stop duplicates [OK]
Common Mistakes:
  • Including %category% causing multiple URLs
  • Using only %postname% losing date info
  • Ignoring SEO impact of URL clarity