【发布时间】:2019-08-22 02:23:39
【问题描述】:
我正在开发一个 wordpress 简码,我想在其中限制来自 xml 的内容。
我用来创建 wordpress 简码的代码是:
function podcast_func( $content = null ){
ob_start();
?>
<script src="https://content.jwplatform.com/libraries/FZ8yNTef.js"></script>
<center><div id="podcast" align="center"></div></center>
<script>
var PodcastplayerInstance = jwplayer("podcast");
PodcastplayerInstance.setup({
playlist: "http://www.cpac.ca/tip-podcast/jwplayer.xml",
androidhls: true,
preload: "auto",
height: 200,
width: 400,
visualplaylist:false,
stretching: "fill",
"plugins": {
"http://www.cpac.ca/tip-podcast/listy.js":{},
'viral-2': {'oncomplete':'False','onpause':'False','functions':'All'}
}
});
</script>
<?PHP
return ob_get_clean();
}
add_shortcode( 'podcast', 'podcast_func' );
在使用这个:<div class="today-podcast" style="text-align: center;">[podcast]</div> 时,它会从这里显示全部内容
http://www.cpac.ca/tip-podcast/jwplayer.xml
问题陈述: 我想知道我应该在上面的 wordpress 短代码中进行哪些更改,以便它只显示 第一个两个项目 或 任何单个项目 从这里http://www.cpac.ca/tip-podcast/jwplayer.xml
【问题讨论】:
-
可以在您的站点上添加一个 xml 解析器,该解析器获取远程数据并删除除第一个 2 之外的所有数据。然后使用服务器上的端点传递到
setup -
@charlietfl 我想知道你是否可以在回答中让我知道我必须做什么。
-
@charlietfl 你在吗?
-
将需要您进行研究.....如何在 php 中使用 cURL 获取远程 xml 数据,如何使用 php 解析 xml 等
标签: javascript php wordpress xml-parsing jwplayer