Genesis – Prevent Transposh from translating Site Title

Transposh Translation Plugin WP header image

I have recently come across the Transposh WordPress Translation plugin, and it looks a pretty useful tool for managing multilingual sites and an alternative to plugins such as qTranslate and WPML. When I have some free time, I’ll try it out on a test install and see how it performs.

However, as clever as it may be, thanks to it’s “automatic” translation capabilities of HTML output, there are inevitably some types of content that should never be translated, such as the WP Site name, particularly if it’s a company name and contains standard English words such as “Joe Blogg’s Clever Machines Inc”, or some such.

Fortunately, Transposh has anticipated this and it is easy to prevent content being translated by wrapping it in span tags with a class of “no_translate”. With a normal WordPress theme this is easy enough to do – just open up header.php and add the span class to the relevant markup.

However, if you are using the Genesis framework from StudioPress, you need to use a Genesis filter to achieve this. Here’s how…

How to add no_translate to Site Title when using Genesis

In Genesis parlance, we are talking about the “SEO Title”, ie the Site Title which is output in the header in either h1 or p tags depending on your Genesis Theme Settings and the page being viewed.

The function that does this, genesis_seo_title() in genesis/lib/structure/header.php has a filter which enables us to replace the default Genesis title outpout markup with our customised version including the span tags with a class of “no_translate”, mentioned above.

Simply paste this code into your Genesis child theme’s functions.php, anywhere above the file’s closing php tag (if it exists):

add_filter( 'genesis_seo_title', 'child_seo_title', 10, 3 );
 * Prevent Transposh plugin from translating site title
 * Adds <span class="no_translate"> within h1/p Genesis SEO Title markup
 * @see genesis_seo_site_title() in genesis/lib/structure/header.php
 * @author Ade Walker <link>
 * @link
 * @param string $title genesis seo title markup
 * @param string $inside Site Title
 * @param string $wrap Either h1 or p, depending on Genesis settings / page requested
 * @return string $title Modified title with new markup added
function child_seo_title( $title, $inside, $wrap ) {

	$inside = sprintf( '<a href="%s" title="%s"><span class="no_translate">%s</span></a>', trailingslashit( home_url() ), esc_attr( get_bloginfo( 'name' ) ), get_bloginfo( 'name' ) );
	$title = sprintf( '<%s id="title">%s</%s>', $wrap, $inside, $wrap );
	return $title;

As you can see, there’s not much code at all.

We simply create a new function, hook it to the genesis_seo_title filter, and build our new markup using the arguments passed by the filter. Note that we need to re-build $inside (this argument is your site’s title wrapped in a link), as this is the element that we want to insert the span tag into. The $wrap argument will either be h1 or p tags, depending on your Genesis Theme Settings.

The nice thing is, by using the filter, you don’t have to worry about dealing with the actual value of $wrap as the main Genesis function takes care of this for you.

A final thought…

You will notice that our version of $inside, defined in the new function, references get_bloginfo() twice. If you are using this code in your own site, you can quite safely replace these with your site name as a string. Although it may be tempting to hardcode the home_url() too, I would leave as is, especially if you use SSL at all, or may do so in the future.

Please leave a comment if you found this useful. 🙂

There are no Comments yet. Why not be the first?

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


+ 2 = three