Hey I am trying to make a if statement, which define the language which is been using in the website first, and then depends on the language, choosing the right content to show up.
Here is the code
[insert_php]$mylocale = get_bloginfo('language');if ($mylocale=="fr-FR"){[/insert_php]
<div>Fr</div>[insert_php]}else{[/insert_php]
<div>Eng</div>[insert_php] } [/insert_php]
WordPress does not allow PHP inside pages or posts, so I use a plugin called “insert PHP” to test the code inside a page, therefore I am using [insert_php]
instead of <?php ?>
.
But the problem is the if statement does not work. it always shows both of “Eng” and “Fr” without picking the right one.
I also tried
[insert_php]$mylocale = get_bloginfo('language');if($mylocale=="fr-FR"):[/insert_php]
<div>Fr</div>[insert_php]; else:[/insert_php]
<div>Eng</div>[insert_php]; endif;[/insert_php]
Does not work as well.
Anyone can help me please? Thank you
Due to the nature of the plugin, you’re going to have to wrap the entire statement in the shortcode tags:
However, from the docs , you should be aware of the following:
It’s likely you won’t have access to
get_bloginfo()
because it is outside of the scope, rendering all of this impossible.