简体   繁体   中英

Output do_shortcode in JavaScript variable

The do_shortcode is not replying me anything.

It should reply me the shortcode value, but when I use this same( only the PHP script) in PHP file it's replying me the value.

But while I'm pushing it in JavaScript variable then it is not replying me anything.

<script>
  function append2(){
     var video2;

     video2='<?php 
        $custom_fields = get_post_custom();
        $mykey_values = $custom_fields['wpcf-picture-movie-link']; 

        foreach ( $mykey_values as $key => $value ) {
            if($value!=''){ 
                do_shortcode($value) ; 
            } 
        } 
      ?> ';

    $("#hide_video2").append(video2);
  }
</script>

Try this code:-

<script>
  function append2(){
     var video2;

     video2='<?php 
        $custom_fields = get_post_custom();
        $mykey_values = $custom_fields['wpcf-picture-movie-link']; 

        foreach ( $mykey_values as $key => $value ) {
            if($value!=''){ 
                echo do_shortcode($value) ; // echo  the shortcode
            } 
        } 
      ?> ';

    $("#hide_video2").append(video2);
  }
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM