• This is what i am trying to do:
    example.com/categoryname/pagename

    I enabled the categories for pages. so i can link my pages to a category.
    but when i visit the page the url is example.com/pagename

    could anybody help me figure out how i can get the category name in between the page and the domain name?

    example.com/categoryname/pagename

    i tried something like this:
    add_rewrite_rule();

    but regular expressions i barely understand.

    Thanks a lot for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey there thias_,

    Hope you’re well! ??

    Try this permalink structure: /%category%/%postname%/ like this: https://prntscr.com/61a2j9 in Settings > Permalinks

    Let me know if it helps! ??

    Best Regards,
    Calvin

    Thread Starter thias_

    (@thias_)

    Hi Calvin!
    Thanks you for your reply.
    The problem is that it are pages (not posts) still have just the
    https://www.domain.com/pagename

    and i would like to have https://www.domain.com/categoryname/pagename

    The premalink settings dont change the url for the pages, or atleast not in my install.

    Can you point me in the right direction?

    Hey there thias_,

    You are welcome and glad to help! ??

    WordPress Pages by default don’t have category can you please tell me you have a code that enable to set category in wordpress pages? I use a plugin to add category but it’s not working for me.

    Looking forward for your reply! ??

    Best Regards,
    Calvin

    Thread Starter thias_

    (@thias_)

    This code enables page categories:

    function page_categories() {
    // Add tag metabox to page
    register_taxonomy_for_object_type('post_tag', 'page');
    // Add category metabox to page
    register_taxonomy_for_object_type('category', 'page');
    }
     // Add to the admin_init hook of your theme functions.php file
    add_action( 'admin_init', 'page_categories' );

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘rewrite rule for page url with categoryname’ is closed to new replies.