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'
            )
        )
    );
}
  • 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. – Andy Macaulay-Brook Jul 24 '16 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. – Andy Macaulay-Brook Jul 24 '16 at 15:09
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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