0

how to get title to custom tags page ? & how to make if condition like to my taxonamy

if ( is_page() ) {
    the_title();
} elseif ( is_tag() ) { 
    single_tag_title();
}

tax:

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'
            )
        )
    );
}
1

To expand your conditional to check for display of one of your terms, you can do this:

if ( is_page() ) {
    the_title();
} elseif ( is_tag() ) { 
    single_tag_title();
} elseif ( is_tax( 'mtags' ); ) { 
    single_term_title('More Tags: ');
}

However, if you use your theme's custom taxonomy template for this taxonomy, taxonomy-mtags.php, then you can just do something like:

<h1 class="page-title">
    <?php single_term_title('More Tags: '); ?>
</h1>

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.