How to get category slug in url (8 posts)

  1. Soron
    Posted 2 years ago #

    Is there a way to add the category slug in the url of a page or post?

    For example:
    I have a post/page with a category "business".

    I do want to get:

    But i get

    In the permalinks setup i choose "costum structure" and added "/%category%/%postname%/" but that doesn't seem to work. :(

    Thank you for your time!

  2. Borko
    Posted 2 years ago #

  3. Soron
    Posted 2 years ago #

    Got his in my mail:
    "Media X wrote:

    Did you enter anything in the Category base field? Check this

    Check what? :)

  4. Rod Whiteley
    Posted 2 years ago #

    I tried the custom structure /%category%/%postname%/ and it worked for me. I have a post with the title Elephant in the category DH, and its URL is now like:


    The category base is not useful for this. It is used to change the URL for category archives. For example, in my site DH is a Source, so I have changed the category base to source. This means that the category archive for DH now has the URL:


  5. Soron
    Posted 2 years ago #

    Yes, It works for posts, but not for pages, which I added categorys for with this code:

    //Pages Tags & Category Meta boxes
    function add_pages_meta_boxes() {
    add_meta_box(   'tagsdiv-post_tag', __('Page Tags'), 'post_tags_meta_box', 'page', 'side', 'low');
    add_meta_box(   'categorydiv', __('Categories'), 'post_categories_meta_box', 'page', 'normal', 'core');
    add_action('add_meta_boxes', 'add_pages_meta_boxes');
    function attach_category_to_page() {
  6. Soron
    Posted 2 years ago #

    It seems you can make a hierarchy in the page attributes. By selecting a parentpage I can get the url i want.


    But then I need a landingpage for each parentpage instead of an archive like the categories.

    Hmm.. will see if this works out.

  7. Borko
    Posted 2 years ago #

    Soron, after i posted that about Category base i realized it has nothing to do with your problem so i removed my comment. You received the notification though :P

  8. automaton
    Posted 1 year ago #

    You could make a custom template for the parent page and generatic an automatic list of child pages there.
    This would work well for relatively small amounts of content (ie not hundreds and hundreds of posts)

Topic Closed

This topic has been closed to new replies.

About this Topic