Hi,
I've been using your framework for a few months now and enjoying it. I'm still finding new features to play with each time I use it. Currently, I'm building a site and not using the Wordpress tagline setting. This causes a problem in that it leaves the ndash separator after the title. I thought I'd be able to filter your semantic_title() function to change the $sep to equal nothing, but it didn't have a filter hook. I rewrote the function to check for a tagline. If there isn't one, it sets the value of $sep to "". If there is a tagline, it adds a hook to filter it.
The one issue I had in doing this was that I had to place the entire function in my custom_functions file and temporarily change the name of your semantic_title() function in semantic-classes.php; otherwise the page would fail to write. I thought I'd share the rewritten function here in case anyone else has had this issue come up. And to find out if I'm over-working it and that there's a simpler way.
Thanks,
Benjamin Gray
<?php
/**
* semantic_title() - Generates semantic classes for the <title> tag with extra SEO love.
*
* @todo refactor code
* @since - 0.2
* @filter semantic_title
*/
function semantic_title( $sep = '–' ) {
$desc = get_bloginfo( 'description' );
if ( $desc != "") : $sep = apply_filters( 'semantic_title_sep', $sep ); // Available filter: semantic_title_sep;
else : $sep = "";
endif;
if ( is_single() ) : wp_title( '»', true, 'right' ); bloginfo( 'name' );
echo ( $sep );
echo $desc;
elseif ( is_page() || is_paged() ) : wp_title( '»', true, 'right' );
bloginfo( 'name' );
echo ( $sep );
echo $desc;
elseif ( is_author() ) : wp_title( 'Archives for ', true, 'left' );
echo ( ' » ' ); bloginfo( 'name' );
echo ( $sep );
echo $desc;
elseif ( is_archive() ) : wp_title( 'Archives for ', true, 'left' );
echo ( ' » ' ); bloginfo( 'name' );
echo ( $sep );
echo $desc;
elseif ( is_search() ) : wp_title('Search Results ', true, 'left' );
echo ( ' » ' ); bloginfo( 'name' );
echo ( $sep );
echo $desc;
elseif ( is_404() ) : wp_title( '404 Error Page Not Found ', true, 'left' );
echo ( ' » ' ); bloginfo( 'name' );
echo ( $sep );
echo $desc;
else : wp_title( '»', true, 'left' ); bloginfo( 'name' );
echo ( $sep );
echo $desc;
endif;
}
function my_custom_title_sepr( $sep ){
if($sep) {
$sep = " — ";
}
return $sep;
}
add_filter( 'semantic_title_sep', 'my_custom_title_sepr' );
?>