How to add shortcode to .site-header-section-right?
-
Hi, do you know how I could add a widget’s shortcode [gtranslate] to the top right of my header? Hopefully both for desktop and mobile, in the top row – right part
This is where I want it:
https://ibb.co/JzqdW1jHere is what the widget (gtranslate) looks like working correctly in the mobile navigation menu (btw, any idea how to make it appear in top of menu instead of bottom?)
This is done by the normal plugin settings, it offers to insert itself into any menu
https://ibb.co/WVB6hDSI asked copilot and gave me a code that didnt work, doesnt do anything, I put it in my functions.php
add_action('wp_head', 'add_gtranslate_to_header');
function add_gtranslate_to_header() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Asegúrate de que el elemento exista para evitar errores
if($('.site-header-section-right').length) {
$('.site-header-section-right').append('<?php echo do_shortcode("[gtranslate]"); ?>');
}
});
</script>
<?php
}I tried putting this code into my header.php
do_shortcode("[gtranslate]");
and it does add the widget but only before or after the header, I tried putting it in multiple parts of my header.php but same thing, either before or after
https://ibb.co/XSJNtvgHere is a code someone wrote for me to add a different widget to a different place in my store which works perfectly:
// Add currency selector in top of shop
add_action('kadence_woocommerce_before_shop_loop_top_row', 'custom_yay_currency_display_currency_switcher');
function custom_yay_currency_display_currency_switcher() {
echo do_shortcode('[yaycurrency-switcher]');
}I don’t know how to transform this code for what I want
UPDATE: I just tried another code written by copilot:
<div class="site-header-top-section-right site-header-section site-header-section-right">
<?php echo do_shortcode('[gtranslate]'); ?>
</div>I put it in multiple places in my header.php, and it shows the widget but in an independent new band before or after the header, but now at least it shows on the right ride
The page I need help with: [log in to see the link]
- You must be logged in to reply to this topic.