Multi-lingual blog – taxonomy – Tarski theme display II

An update to my recent post about tagging post languages with the language used. Another thing I wanted is the display of flags instead of the short code of the language. In this post I explain how I achieved that with one additional plugin and an extension of code (Tarski extension plugin) shown in the previously mentioned post.


Before continuing, one has to set up a new taxonomy as decribed in the previous post.

Adding taxonomy flags

I first tried to use the Ultimate CMS extended fields for adding images, but there seems to be no programmatical interface to get the values, so I decided to use the simpler approach and install the plugin Sideways8 Simple Taxonomy Images. After installing and activating the plugin you will find a new column in the table of Languages under Posts, called Taxonomy Image.

For the actual language flags I used the freely available icons from the Drupal project, available from the Drupal Language Icons web page.

Displaying a language flag in the post header

A small variation of the code posted before allows the flag to show up instead of the language short codes.

 * @package Tarski_Meta_Post_Language
 * @version 0.2
Plugin Name: Tarski Meta Post Language
Plugin URI:
Description: Add the language of the post to the meta data
Author: Norbert Preining
Version: 0.2
Author URI:
function add_language_to_metadata($metadata) {
    global $post;
    $term_list = wp_get_post_terms($post->ID, 'language', array("fields" => "all"));
    $first = true;
    foreach ($term_list as $term) {
      if (!$first) {
        $metadata .= ', ';
        $first = false;
      $imgsrc = s8_get_taxonomy_image($term, 'full');
      if ($imgsrc != false) {
        $metadata .= '<a href="/?language=' . $term->slug . '">' . $imgsrc . '</a>';
      } else {
        $metadata .= '<a href="/?language=' . $term->slug . '">' . $term->slug . '</a>';
    $metadata .= ' | ';
    return $metadata;
add_filter('th_post_metadata', 'add_language_to_metadata', 0);

As before, putting this file as tarski-meta-post-language.php into the folder wp-content/plugins/tarski-meta-post-language/ on your blog side allows you to activate it in the plugin setting. But do this only if you are using the Tarski theme, I don’t know what will happen if another theme is used.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">