I want to display a custom taxonomy page.
$microblogging_taxonomy_slug="theme";
$microblogging_taxonomy_singular="theme";
$microblogging_taxonomy_plural="themes"
$labels = array(
'name' => $microblogging_taxonomy_plural,
'singular_name' => $microblogging_taxonomy_singular,
'search_items' => sprintf( __( 'Search %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_plural) ),
'all_items' => sprintf( __( 'All %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_plural) ),
'parent_item' => sprintf( __( 'Parent %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'parent_item_colon' => sprintf( __( 'Parent %s :',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'edit_item' => sprintf( __( 'Edit %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'update_item' => sprintf( __( 'Update %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'add_new_item' => sprintf( __( 'Add new %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'new_item_name' => sprintf( __( 'New %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'menu_name' => $microblogging_taxonomy_plural,
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => $microblogging_taxonomy_slug ),
);
register_taxonomy( MB_CUSTOM_TAX_1_NAME, array( "post" ), $args );
now I want to create a template for this page "mysite.dev/theme/". Is it possible?
I create this taxonomy with a plugin and so I would use a filter like
add_filter( 'taxonomy_template', 'mb_get_custom_taxonomy_template' );
For example I use a function, attached to the 'archive_template' filter hook, to replace tax original theme template
function mb_get_custom_post_type_template_archive($archive_template) {
global $taxonomy,$term,$wp_query;
global $mb_css_js_version;
if (is_tax() && $taxonomy == MB_CUSTOM_TAX_1_NAME) {
$archive_template = MB_TEMPLATE_CUSTOM_TAX_1_DIR . "index.php";
}
else if (is_post_type_archive(MB_POST_TYPE)) {
$archive_template = MB_TEMPLATE_ARCHIVE_DIR . "post_type_archive/index.php";
}
return $archive_template;
}
With this function I can view my plugin template
ex. http://ift.tt/1GIv5AO http://ift.tt/1k9AuXa
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire