Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.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 如何在数组中调用自定义字段post元函数_Php_Wordpress - Fatal编程技术网

Php 如何在数组中调用自定义字段post元函数

Php 如何在数组中调用自定义字段post元函数,php,wordpress,Php,Wordpress,嗨,我想视频链接将调用自定义字段 这是我的代码: <?php the_post_thumbnail('slider-thumb', array('class' => 'rsImg', 'data-rsvideo' => 'http://www.vimeo.com/61893383' )); ?> 我的代码是: <?php the_post_thumbnail('slider-thumb', array('class' => 'rsImg', 'data

嗨,我想视频链接将调用自定义字段

这是我的代码:

<?php the_post_thumbnail('slider-thumb', array('class' => 'rsImg', 'data-rsvideo' => 'http://www.vimeo.com/61893383' )); ?>

我的代码是:

 <?php the_post_thumbnail('slider-thumb', array('class' => 'rsImg', 'data-rsvideo' => '<?php echo get_post_meta($post->ID, video, true); ?>' )); ?>

没有语法错误。但视频没有运行


请帮助我。

您正在嵌套PHP标记。那是不对的

根据第一个示例中的正确语法,它接受URL

假设你的函数
get\u post\u meta($post->ID,video,true)返回正确的URL,然后您可以像这样修改代码-

<?php 
    $myVidURL = get_post_meta($post->ID, 'video', true);
    the_post_thumbnail('slider-thumb', array('class' => 'rsImg', 'data-rsvideo' =>  $myVidURL )); 
?>


在第二个代码中,我的代码是:,如何添加
…?>。你可以像这样直接使用
像这样试试,这可能有用。+1感谢你在这方面击败了我,感谢你有足够好的榜样去偷东西。