audio_list(get_the_content())
function audio_list($data){
$content = strip_tags($data);
$audiolist = explode("[/audio]", $content);
$audiolist = array_filter($audiolist);
return $audiolist;
}
现在,我正在使用一个自定义函数,该函数剥离音频URL,并从URL中拆分文件名,并在我的站点中显示真实文件名作为音频的名称。我需要将真实姓名更改为媒体标题。我怎样才能做到这一点 ??在Word中,嵌入式播放器媒体ID不可用。在批量上传的情况下,媒体没有与任何帖子相关联,因此父帖子附件概念也不起作用。还有其他方法可以获取媒体标题吗?
首先获取上传的音频文件作为数组
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'audio',
'numberposts' => -1
);
$audiofiles = get_posts($args);
创建一个与文件网址匹配的if条件
foreach ($audiofiles as $file)
{
$urls = wp_get_attachment_url($file->ID);
if($urls == 'url from the content'){
$title = $file->post_title;
}else {
$title = 'file real name';
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句