I have a custom taxonomy "Portfolio Categories", and a few these categories say "Cloth", "Shoes", ...
When open some category page, i want the title to be like 'Site Name | Cloth', but with wp_title(), it becomes 'Site Name | Portfolio Categories | Cloth'
How do i remove the "Portfolio Categories" fr开发者_开发技巧om the title?
simply use the wp_title filter (some info here: http://adambrown.info/p/wp_hooks/hook/wp_title)
Are you saying you have a hierarchical custom taxonomy and you want the second-level taxonomies to have URLs which don't include their parent's name in them?
If you are saying that then, as far as I understand it, that's not possible - because it's hierarchical. If you want to have a url such as:
http://yourdomain.com/cloth/
then you'll need a non-hierarchical taxonomy.
The alternative is to set up a custom page template and create a page called 'Cloth' and select your new template for this page. In your template you would create a loop which output only the posts that are in this custom taxonomy.
Try putting this in your header.php:
<title><?php
global $page, $paged, $post;
if (is_tax()) {
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$term_title = $term->name;
echo "$term_title | ";
} else {
wp_title( '|', true, 'right' );
}
// Add the blog name.
bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
echo " | $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
?></title>
精彩评论