Again,
I quickly test the code with WP 4.0 and with theme twenty fourteen-xili… https://2014.extend.xiligroup.org – All work. The most courant error is to forget content (no closing tag after a text) so I rewrite a little the example:
/**
* SHORTCODE LINKPOST - example
*
* Example with content: [linkpost lang="fr_FR"]vers ce post en fran?ais[/linkpost], with no content: arrow by default
*
* @since 2010 - updated 2014
*
*/
function xiliml_build_linked_posts_shortcode( $atts, $content=null ) {
global $post;
$otherpost = false;
$arr_result = shortcode_atts(
array( 'lang'=>'',
'title'=>'')
, $atts);
$language = xiliml_get_language( $arr_result['lang'] ); /* test if lang is available */
if ( $language !== false ) {
$otherpost = get_post_meta($post->ID, 'lang-'.$language->slug, true);
}
if (!$content) $content = '→'; // if shortcode don't have content !!
if ( $otherpost ) {
if ('' == $arr_result['title']) {
$obj_lang = xiliml_get_lang_object_of_post( $otherpost );
if ( false !== $obj_lang ) {
$description = $obj_lang->description;
$title = __( 'A similar post in', 'twentyfourteen').' ' . $description; // adapt the domain to your theme
} else {
$title = __( 'Error with target post #', 'twentyfourteen') . $otherpost;
}
}
$output = '<a href="' . get_permalink( $otherpost ).'" title="' . $arr_result['title'] . '">'. $content . '</a>';
/* this link above can be enriched by image or flag */
} else {
$output = '<a href="#" title="' . __('Error: other post not present !!!', 'xili-language' ) . '">' . $content . '</a>';
}
return $output;
}
add_shortcode( 'linkpost', 'xiliml_build_linked_posts_shortcode');
Add (and adapt) this code in functions.php of your theme…
Hope that help you !