我正在尝试将wordpress中的图像添加到我的php页面。我已经为wordpress调用了wp-load.php:
require_once("blog/wp-load.php");
但是,我不知道如何调用特定的帖子,我可以使用该帖子中的图像转到我的flex-slider。
<div class="flexslider">
<ul class="slides">
<li><img src="<?php
//????
?>" />
如何调用特定帖子,然后从该特定帖子我可以获取所有图像文件路径,然后将其粘贴到图像的src上?我希望它在一个帖子里面,所以如果我想改变图像,我只需编辑帖子。
答案 0 :(得分:1)
您是否尝试过使用get_posts()?
$args = array( 'post_type' => 'attachment',
'posts_per_page' => -1,
'post_status' => 'any',
'post_parent' => **THE_ID_OF_THE_POST** );
$attachments = get_posts( $args );
//ETC...