Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Soron

    (@soron)

    Got his in my mail:
    “Media X wrote:

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

    Check what? ??

    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:

    https://example.com/dh/elephant/

    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:

    https://example.com/source/dh/

    Thread Starter Soron

    (@soron)

    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');
    
    add_action('init','attach_category_to_page');
    function attach_category_to_page() {
        register_taxonomy_for_object_type('category','page');
    }
    //end
    Thread Starter Soron

    (@soron)

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

    Thus:
    https://www.mydomain.com/parentpage/page

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

    Hmm.. will see if this works out.

    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 ??

    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)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to get category slug in url’ is closed to new replies.