Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.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 只显示第一个已安装的wordpress_Php_Css_Wordpress_Oembed - Fatal编程技术网

Php 只显示第一个已安装的wordpress

Php 只显示第一个已安装的wordpress,php,css,wordpress,oembed,Php,Css,Wordpress,Oembed,我正在尝试为视频和音频post格式创建一个函数,以便仅显示内容中的第一个oembed媒体 我能够想出如何创建内容过滤器,并使该功能仅适用于视频和音频post格式 add_filter( 'the_content', 'first_oembed_only', 8 ); function first_oembed_only($content) { if(has_post_format(array('video','audio'))) { //show first oembed onl

我正在尝试为视频和音频post格式创建一个函数,以便仅显示内容中的第一个oembed媒体

我能够想出如何创建内容过滤器,并使该功能仅适用于视频和音频post格式

 add_filter( 'the_content', 'first_oembed_only', 8 );
function first_oembed_only($content) { 
  if(has_post_format(array('video','audio'))) {
    //show first oembed only
    //if other media and oembeds exist remove
    //make a div with the remaining content that only allows text and images
  return $content;
  }
} 
该函数还需要执行的另一项任务是删除任何oEmbed或媒体,但随后包含在div中的图像除外

我发现我可以使用preg match来查找[embed]和[video]短代码和/或使用css来查找短代码,对吗?这是最好的选择吗

例如:

.single-format-video iframe
.single-format-video video {
 display: none;
}
对我来说,最棘手的部分是,除了第一个oembed外,我将如何围绕内容包装div