0

I need to make my wordpress permalink like the following

Permalink For Category:

 www.mydomain.com/category/%category%

Permalink For Posts:

 www.mydomain.com/category/%category%/article/%postname%

Is there any specific code i can use with .htaccess or any plugin that might help

  • Have you tried anything? – Rahil Wazir Jan 25 '14 at 10:04
  • Yes and the main issue is..! 1 permalink is working If i put a special slug for categories the posts does not work..! – Amanullah Tanweer Jan 25 '14 at 10:49
1

This might help you:

Go to your Settings => Permalinks => Cutom Structure

And paste this:

/category/%category%/article/%postname%/

Also paste this on Category Base field:

category

This will work for category but when you visit any post you will be welcomed with 404 page not found (Isn't it nice?).

So stealing from this answer

Add this code to your themes functions.php file:

add_action( 'init', 'wpa58471_category_base' );
function wpa58471_category_base() {
    // Remember to flush the rules once manually after you added this code!
    add_rewrite_rule(
        // The regex to match the incoming URL
        'category/([^/]+)/([^/]+)/([^/]+)(/[0-9]+)?/?$',
        // The resulting internal URL
        'index.php?category_name=$matches[1]/$matches[2]&name=$matches[3]&paged=$matches[4]',
        // Add the rule to the top of the rewrite list
        'top' );
}

And switch back to Settings => Permalinks and click Save Changes.

| improve this answer | |
  • Love you thanks man.. 404 was making my mind blow – Amanullah Tanweer Jan 25 '14 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.