Genesis – Prevent Transposh from translating Site Description

Transposh Translation Plugin WP header image

Following on from my recent tutorial on how to prevent the Transposh WordPress Translation plugin from automatically translating the Genesis SEO Site Title, I thought it would be useful to show how to make the same modification to the Genesis SEO Site Description.

As discussed in that previous article, Transposh does not translate any content wrapped in span tags with a class of “no_translate”. Depending on the Site Description, you may not want to have this translated and, if you are using a Genesis child theme, the correct way to add these span tags is by using an appropriate Genesis filter.

This tutorial shows you how to do it…

How to add no_translate to Site Description when using Genesis

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

The Genesis function that does this, genesis_seo_site_description(), in genesis/lib/structure/header.php, has a filter which enables us to replace the default Genesis site description outpout markup with our customised version incorporating the “no_translate” span tags 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_description', 'child_seo_site_description', 10, 3 );
/**
 * Prevent Transposh plugin from translating site description
 *
 * Adds <span class="no_translate"> within h1/p Genesis SEO Site Description markup
 * @see genesis_seo_site_description() in genesis/lib/structure/header.php
 *
 * @author Ade Walker <link http://www.studiograsshopper.ch>
 * @link http://www.studiograsshopper.ch/code-snippets/genesis-prevent-transposh-from-translating-site-description/
 *
 * @param string $title genesis seo site description markup
 * @param string $inside Site Description
 * @param string $wrap Either h1 or p, depending on Genesis settings / page requested
 *
 * @return string $title Modified site description with new markup added
 */
function child_seo_site_description( $description, $inside, $wrap ) {

	$description = $inside ? sprintf( '<%s id="description"><span class="no_translate">%s</span></%s>', $wrap, $inside, $wrap ) : '';
	
	return $description;
}

Once again, a simple and elegant way of customising Genesis.

We create a new function, hook it to the genesis_seo_description filter, and build our new markup using the arguments passed by the filter. As you can see, it is slightly less involved to modify the Site Description than to modify the Site Title, and we only need to re-build the $description argument and then return it.

Note that because we are using a filter which is run just before the calling function returns its output, we don’t have to worry about any of the logic built into the calling functions, such as the value of the $wrap argument, which will either be h1 or p tags, depending on your Genesis Theme Settings.

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>

*


7 × five =