On a multilanguage blog I want to be able to add language codes to the post title for screen readers. I am using custom fields to do this.
I added the following code to the template files:
In the header.php underneath the <body>:
<?php $language_class = get_post_meta($post->ID, 'language', true); ?>
For the post title (category or single post):
<h2 class="pc"> <a class="<?php
if ($language_class=="en") {
echo $language_class;
} else {
echo "sl";
}
?>" href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
However it is not working. I have tried different things. And from what I can tell it is not getting the $language_class in the h2 tag.
If I use <?php echo $language_class;?> it shows an empty class tag.
I am getting a bit lost in the documentation. Can anyone see what I am doing wrong, or someone who can point me in the right direction?
Many thanks. :-)
Reference documentation:
http://codex.wordpress.org/Using_Custom_Fields
http://www.kriesi.at/archives/how-to-use-wordpress-custom-fields