function t_shortcode($atts, $content = null){
$lang = strtolower($atts['lang']);
$content = "<div id='translator' class='translate_".$lang."'>".$content."</div>";
if($lang == $_SESSION['language']):
return $content;
endif;
}
I’m trying to get the content between the shortcodes, apply a function to it in index.php and the return back the $content of the shortcode with the divs included.
the second function that i’d like to apply to the shorcode function is:
function display($shortcodecontent, $noofchars){
$content2 = mb_substr($shortcodecontent,0,$noofchars);
return $content2;
}
so that I can use:
// 13 is the number of characters
The following adds the shortcode
[my_t_shortcode]
, which accepts an attribute ‘lang’, and applys the above mentioned function to the content.And the custom function:
If that all
wpse41477_display
does, I would strongly recommend that you include it directly in the shortcode handler (see the comments).The above code is not tested.