Try using the do_shortcode() function to execute the shortcode, don’t print it.
https://developer.ww.wp.xz.cn/reference/functions/do_shortcode/
Thread Starter
kevin
(@kevinwebdesign1)
Many thanks Lorro
I fixed it. Happy to meet you.
Thread Starter
kevin
(@kevinwebdesign1)
Hi Lorro
May I know if the website have multi-language, how to divide to (CN or EN)
add_action( ‘woocommerce_after_shop_loop’, ‘add_my_text’, 20 );
What multi-language plugin are you using?
Thread Starter
kevin
(@kevinwebdesign1)
Hi Lorro
This website is using the Polylang – https://ww.wp.xz.cn/plugins/polylang/
It looks like Polylang uses a cookie to store the currently selected language. To verify, inspect your cookies. Your browser should have an option to allow this. The cookie name: is pll_language
So inside your function you can inspect the value of the cookie and branch accordingly:
if( isset($_COOKIE['pll_language'] ) ) {
$language_code = $_COOKIE['pll_language'];
switch( $language_code ) {
case 'cn':
// etc
break;
case 'en':
// etc
Not tested so some experimentation and php skills will be needed to get it working.
We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.