I am trying to get the link of custom term.

The problem that I have prefix for all urls set in Permalinks like that


So I have following links for default terms


It works great.

But I have registered custom taxonomy using register_taxonomy function.

I try to get taxonomy archive url


This function returns link in the following format


And this link works perfectly, but I need it to be


How can I achieve this ?


Arguments used to register taxonomy

 /* Set up the arguments for the my_taxonomy taxonomy. */
        $args = array(
            'public' => true,
            'show_ui' => true,
            'show_in_nav_menus' => true,
            'show_tagcloud' => true,
            'show_admin_column' => true,
            'hierarchical' => false,
            'query_var' => 'my_taxonomy',

            /* Only 2 caps are needed: 'manage_my_taxonomy' and 'edit_posts'. */
            'capabilities' => array(
                'manage_terms' => 'manage_my_taxonomy',
                'edit_terms' => 'edit_posts',
                'delete_terms' => 'edit_posts',
                'assign_terms' => 'edit_posts',

            /* The rewrite handles the URL structure. */
            'rewrite' => array(
                'slug' => 'my_taxonomy',
                'with_front' => false,
                'hierarchical' => false,
                'ep_mask' => EP_NONE

            /* Labels used when displaying taxonomy and terms. */
            'labels' => array(
                'name' => __('My Taxonomy', 'my_taxonomy'),
                'singular_name' => __('My Taxonomy', 'my_taxonomy'),
                'menu_name' => __('My Taxonomy', 'my_taxonomy'),
                'name_admin_bar' => __('My Taxonomy', 'my_taxonomy'),
                'search_items' => __('Search my_taxonomy', 'my_taxonomy'),
                'popular_items' => __('Popular my_taxonomy', 'my_taxonomy'),
                'all_items' => __('All My Taxonomy', 'my_taxonomy'),
                'edit_item' => __('Edit My Taxonomy', 'my_taxonomy'),
                'view_item' => __('View My Taxonomy', 'my_taxonomy'),
                'update_item' => __('Update My Taxonomy', 'my_taxonomy'),
                'add_new_item' => __('Add New My Taxonomy', 'my_taxonomy'),
                'new_item_name' => __('New My Taxonomy Name', 'my_taxonomy'),
                'separate_items_with_commas' => __('Separate my_taxonomy with commas', 'my_taxonomy'),
                'add_or_remove_items' => __('Add or remove my_taxonomy', 'my_taxonomy'),
                'choose_from_most_used' => __('Choose from the most used my_taxonomy', 'my_taxonomy'),

        /* Register the 'my_taxonomy' taxonomy. */
        register_taxonomy('my_taxonomy', array('post'), $args);
  • What are the arguments you used to register the taxonomy?
    – Milo
    Dec 24, 2016 at 16:30
  • @Milo thanks for comment I have just added taxonomy registration code
    – Putinhello
    Dec 24, 2016 at 17:20

1 Answer 1


Your permalink structure prefix is controlled by the with_front argument:

'rewrite' => array(
    'slug' => 'my_taxonomy',
    'with_front' => true, // changed to include prefix
    'hierarchical' => false,
    'ep_mask' => EP_NONE
  • Thanks for answer, now link is correct, but results in 404 error. What can be wrong ?
    – Putinhello
    Dec 24, 2016 at 18:03
  • flush_rewrite_rules(); helped to solve the problem !!
    – Putinhello
    Dec 24, 2016 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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