WordPress.org

Support

Support » Plugins and Hacks » Simple Taxonomies get_term_title problems

Simple Taxonomies get_term_title problems

  • Hi guys,

    I’m running WP 2.9.2 on Stereokill.net, and using Yoast’s Simple Taxonomies plugin to set up a couple of custom taxonomies.

    I’m trying to configure my theme’s archive.php template to include a custom title output for the taxonomies, much as it would for tags, categories, and so on. The important part of the archive.php code looks something like this:

    <?php if ( is_category() ) : ?>
            <h1 class="home-title"><?php printf( __('%s Archive', 'arras'), single_cat_title() ) ?></h1>
        <?php elseif ( is_tag() ) : ?>
            <h1 class="home-title"><?php printf( __('%s', 'arras'), single_tag_title() ) ?></h1>
    <strong>    <?php elseif(isset($wp_taxonomies)) : ?>
            <h1 class="home-title"><?php printf( __('%s', 'arras'), get_yoast_term_title() ) ?></h1></strong>
        <?php elseif ( is_day() ) : ?>
            <h1 class="home-title"><?php printf( __('Archive for %s', 'arras'), get_the_time( __('F jS, Y', 'arras') ) ) ?></h1>
        <?php elseif ( is_month() ) : ?>
            <h1 class="home-title"><?php printf( __('Archive for %s', 'arras'), get_the_time( __('F, Y', 'arras') ) ) ?></h1>
        <?php elseif ( is_year() ) : ?>
            <h1 class="home-title"><?php printf( __('Archive for %s', 'arras'), get_the_time( __('Y', 'arras') ) ) ?></h1>
        <?php elseif ( is_author() ) : ?>
            <h1 class="home-title"><?php _e('Author Archive', 'arras') ?></h1>
        <?php else : ?>
            <h1 class="home-title"><?php _e('Archives', 'arras') ?></h1>
        <?php endif; ?>

    What you see in bold was added by me, using the get_yoast_term_title function in the plugin to call the title, and to some extent it works. WP outputs the taxonomy term name at the top of archive pages, as it should. The problem is that what comes out isn’t the ‘pretty’ version of the term title; it comes out as hyphen-separated text. I tried using a fix I found with a Google search, like this:

    <?php
    if(isset($wp_taxonomies)) {
    	// This is getting the friendly version of a taxonomy
    	// - not the hyphenated get_yoast_term_title()
    	$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
    	if($term) {
    		echo '<h2 class="pagetitle">'.$term->name.'</h2>';
    	}
    }
    ?>

    But that doesn’t work as I would like it to.

    Any input on how to persuade Simple Taxonomies to output the term title properly-formatted would be much appreciated!

    Cheers in advance,

    M

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Simple Taxonomies get_term_title problems’ is closed to new replies.