0

I need to create Custom tags archive like normal tags in post_type "post".

ex: i need this http://sitename.com/mtag/test work like http://sitename.com/tag/test

add_action( 'init', 'create_mtags_taxonomy' );
function create_mtags_taxonomy() {
    $labels = array(
        'name'                           => 'More Tags',
        'singular_name'                  => 'More Tags',
        'menu_name'                      => 'More Tags',
    );
    register_taxonomy(
        'mtags',
        'post',
        array(
            'label' => __( 'More Tags' ),
            'hierarchical' => false,
            'labels' => $labels,
            'public' => true,
            'show_in_nav_menus' => false,
            'show_tagcloud' => true,
            'has_archive' => true,
            'show_admin_column' => true,
            'rewrite' => array(
                'slug' => 'mtag'
            )
        )
    );
}
2
  • At first glance, that should just work, as long as you've flushed your rewrite rules. You can do that by going into the settings and saving permalinks again. Commented Jul 24, 2016 at 14:16
  • No problem. I've pasted my comment into an answer. If you don't mind accepting it, that will show the question as answered and help keep the site tidy. Commented Jul 24, 2016 at 15:09

1 Answer 1

1

At first glance, that should just work, as long as you've flushed your rewrite rules. You can do that by going into the settings and saving permalinks again.

3

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.