WP Framework Forums

A blank WordPress Theme Framework

Register or log in - lost password?

WP Framework Forums » Feature Request

Semantic Title Separator When There Is No Wordpress Tagline

(1 post) (1 voice)
  • Started 4 months ago by benjamin
  • Related Topics:
    1. Remove » from title?
    2. Semantic body classes: no "loggedin"
    3. Custom body background colours and Semantic Body question
    4. Consistency with Wordpress
    5. Wp Framework 0.4 and Wordpress 2.8.1

Tags:

  • bloginfo('description')
  • semantic_title()
  • tagline
  • title separator
  1. benjamin
    Member

    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( '&raquo', 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' );

    ?>

    Posted 4 months ago #

RSS feed for this topic

Reply

You must log in to post.

WP Framework Forums is proudly powered by bbPress.