Php 只显示第一个已安装的wordpress
我正在尝试为视频和音频post格式创建一个函数,以便仅显示内容中的第一个oembed媒体 我能够想出如何创建内容过滤器,并使该功能仅适用于视频和音频post格式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
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