Support » Developing with WordPress » Write shortcode inside javascript file

  • Hi
    How can I add a shortcode inside a javascript file?

    I have the Astra Pro theme to my website, and have written this code:

    $(document).ready(function(){
    
    $( ".site-branding" ).append( "<?php echo do_shortcode('[astra_woo_mini_cart]'); ?>" );
    
    });

    I have also tryed to add the code into the header.php and footer.php, but nothing happen?

    Note: I have enabled https://code.jquery.com/jquery-3.5.1.min.js in my header.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.