简体   繁体   English

在JavaScript变量中输出do_shortcode

[英]Output do_shortcode in JavaScript variable

The do_shortcode is not replying me anything. do_shortcode没有回复我任何事情。

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. 它应该回复我的简码值,但是当我在PHP文件中使用相同的(仅PHP脚本)时,它将回复我的值。

But while I'm pushing it in JavaScript variable then it is not replying me anything. 但是,当我在JavaScript变量中推送它时,它什么也没有回复。

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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