Bird
Raised Fist0
Wordpressframework~20 mins

Permalink structure in Wordpress - Practice Problems & Coding Challenges

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
Challenge - 5 Problems
🎖️
Permalink Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
1:30remaining
How does WordPress handle a custom permalink structure with %postname%?
If you set your permalink structure to /%postname%/, what will be the URL for a post titled "Hello World"?
Ahttps://example.com/?p=hello-world
Bhttps://example.com/hello-world/
Chttps://example.com/2024/hello-world/
Dhttps://example.com/category/hello-world/
Attempts:
2 left
💡 Hint
Think about how %postname% replaces the slug in the URL.
📝 Syntax
intermediate
1:30remaining
Which permalink structure is valid for including year, month, and post ID?
Choose the correct permalink structure to show year, month, and post ID in the URL.
A/%year%/%monthnum%/%post_id%/
B/%year%/%post%/%id%/
C/%year%/%month%/%postid%/
D/%y%/%m%/%pid%/
Attempts:
2 left
💡 Hint
WordPress uses specific tags like %year%, %monthnum%, and %post_id%.
state_output
advanced
2:00remaining
What is the effect of changing permalink structure on existing links?
After changing the permalink structure from /%year%/%postname%/ to /%postname%/, what happens to old URLs?
AOld URLs show the homepage instead of the post.
BOld URLs automatically redirect to new URLs without any setup.
COld URLs continue to work without any change.
DOld URLs return 404 errors unless redirects are set up.
Attempts:
2 left
💡 Hint
Think about how WordPress handles URL changes without redirects.
🔧 Debug
advanced
2:00remaining
Why does WordPress show a 404 error after setting a custom permalink?
You set a custom permalink structure but all posts show 404 errors. What is the most likely cause?
AThe .htaccess file is missing or not writable.
BThe WordPress theme is incompatible.
CThe post titles are too long.
DThe database is corrupted.
Attempts:
2 left
💡 Hint
Permalinks rely on server rewrite rules.
🧠 Conceptual
expert
2:30remaining
How does WordPress prioritize permalink matching when multiple structures overlap?
If you have two custom post types with similar permalink structures, how does WordPress decide which content to show?
AWordPress throws an error due to ambiguous URLs.
BWordPress merges both post types and shows combined content.
CWordPress matches the first registered rewrite rule that fits the URL.
DWordPress shows a list of all matching posts from both types.
Attempts:
2 left
💡 Hint
Rewrite rules are checked in order of registration.

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