Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php “如何显示自定义字段”;“允许此字段的多个实例”;在类型上?_Php_Wordpress_Types_Custom Fields - Fatal编程技术网

Php “如何显示自定义字段”;“允许此字段的多个实例”;在类型上?

Php “如何显示自定义字段”;“允许此字段的多个实例”;在类型上?,php,wordpress,types,custom-fields,Php,Wordpress,Types,Custom Fields,我为播放列表URL创建类型自定义字段。我会有Spotify、Youtube或Soundcloud的URL。有些播放列表会有spotify url和youtube url,有时有些播放列表会有soundcloud url或youtube url。当我添加一个新的url时,它可以工作,但我如何显示它。例如,我希望它像这样显示 我的代码是 我希望在单击“立即收听”按钮时显示它,这样spotify、youtube或soundcloud就会出现(我在自定义字段中输入的url) 这是我的动态代码。如何在“立

我为播放列表URL创建类型自定义字段。我会有Spotify、Youtube或Soundcloud的URL。有些播放列表会有spotify url和youtube url,有时有些播放列表会有soundcloud url或youtube url。当我添加一个新的url时,它可以工作,但我如何显示它。例如,我希望它像这样显示

我的代码是

我希望在单击“立即收听”按钮时显示它,这样spotify、youtube或soundcloud就会出现(我在自定义字段中输入的url)

这是我的动态代码。如何在“立即侦听”按钮中显示自定义字段“允许此字段的多个实例”? 看我的截图,你知道我在说什么。

我知道我必须更改“选项栏”代码以显示多个实例

<div class="option-bar">
    <a target="_blank" href="<?php echo(types_render_field('spotify-url', array('raw' => true) )); ?>">Spotify</a> or <a target="_blank" href="<?php echo(types_render_field('youtube-url', array('raw' => true) )); ?>">Youtube</a>
</div>


正确);?>"> 

听着 或

听着 或 正确);?>“>
$paid\u mp4\u array=get\u post\u meta(获取\u ID(),'wpcf-paid-mp4');
if($PAYED\u mp4\u阵列){
foreach($k=>v的已支付\u mp4\u数组){
echo sprintf(“”,$k,$v);
}
}
  <?php

    $args  = array('post_type' => 'music-playlist');
    $query = new WP_Query($args);

    $cntr = 0;

    while( $query -> have_posts() ) : $query -> the_post(); $cntr++; ?>

<section class="row-wrap">
    <div class="row-inner music-wrapper">

        <?php if ($cntr % 2 == 1) { ?>

        <div class="poster-wrap">
            <img class="poster" src="<?php echo(types_render_field('artwork', array('raw' => true) )); ?>"> 
        </div>

        <div class="poster-content">
            <h1><?php echo(types_render_field('playlist-name', array('raw' => true) )); ?></h1>
            <p><?php echo(types_render_field('description', array('raw' => true) )); ?></p>

            <button class="btn-wrap">
                <div class="btn">listen now</div>
            </button>

            <div class="option-bar">
                <a target="_blank" href="<?php echo(types_render_field('spotify-url', array('raw' => true) )); ?>">Spotify</a> or <a target="_blank" href="<?php echo(types_render_field('youtube-url', array('raw' => true) )); ?>">Youtube</a>
            </div>
        </div>


        <?php } else { ?>

        <div class="poster-content">
            <h1><?php echo(types_render_field('playlist-name', array('raw' => true) )); ?></h1>
            <p><?php echo(types_render_field('description', array('raw' => true) )); ?></p>

            <button class="btn-wrap">
                <div class="btn">listen now</div>
            </button>

            <div class="option-bar">
                <a target="_blank" href="<?php echo(types_render_field('spotify-url', array('raw' => true) )); ?>">Spotify</a> or <a target="_blank" href="<?php echo(types_render_field('youtube-url', array('raw' => true) )); ?>">Youtube</a>
            </div>
        </div>

        <div class="poster-wrap">
            <img class="poster" src="<?php echo(types_render_field('artwork', array('raw' => true) )); ?>"> 
        </div>
        <?php } ?>

    </div>
</section>
$paid_mp4_array = get_post_meta( get_the_ID(), 'wpcf-paid-mp4');
if($paid_mp4_array){
  foreach($paid_mp4_array as $k => $v){
    echo sprintf('<div id="video-%1$s"><source src="%2$s" type="video/mp4" /></div>', $k, $v);
  }
}