- This topic has 3 replies, 2 voices, and was last updated 9 years, 6 months ago by
Andrew Misplon.
Tagged: meta slider qTanslate
- AuthorPosts
- October 31, 2015 at 1:59 pm #2616
Andrew MisplonKeymasterHi Jordi
Great to hear from you; thanks for your support.
I think the easiest would be to copy header.php (not cut) from the parent theme folder and paste it into your child theme folder. Then, replace line 66:
<?php ultra_render_slider(); ?>
with the following:
<?php $currentlang = get_bloginfo( 'language' ); if ( is_front_page() ) { if ( $currentlang=="es-ES" ) { echo do_shortcode( '[metaslider id=32]' ); // Spanish } if ( $currentlang=="ca-CA" ) { echo do_shortcode( '[metaslider id=33]' ); // Catalan } } else { ultra_render_slider(); } ?>
The only additional step required would be to replace the Meta Slider ID’s of 32 and 33 that I’ve used above, with your own.
Let me know how that goes 🙂 Thanks
November 2, 2015 at 1:45 am #2617
jorditrunoParticipantThis reply has been marked as private.November 2, 2015 at 8:44 am #2619
Andrew MisplonKeymasterNicely done! Thanks for making a few changes to the code I sent. For anyone else reading, the final code Jordi used to switch Meta Sliders based on language was:
<?php $currentlang = get_bloginfo( 'language' ); if ( is_front_page() ) { if ( $currentlang=="es-ES" ) { echo do_shortcode( "[metaslider id=66]" ); // Spanish } if ( $currentlang=="es-CA" ) { echo do_shortcode( "[metaslider id=133]" ); // Catalan } } else { ultra_render_slider(); } ?>
The reason I originally used single quotes in
do_shortcode
is that it allows the use of double quotes within the shortcode. Some shortcodes might have double quotes within the shortcode. For example, if you use LayerSlider instead of Meta Slider, the LayerSlider shortcode looks as follows:[layerslider id="1"]
To use that shortcode within
do_shortcode
you need to use single commas:echo do_shortcode( '[layerslider id="1"]' );
Ref: https://developer.wordpress.org/reference/functions/do_shortcode/
If you run into any further challenges, please, let me know.
All the best with your site 🙂
- AuthorPosts
You must be logged in to reply to this topic.