【问题标题】:Add images from post in wordpress to flexslider将 wordpress 中的帖子中的图像添加到 flexslider
【发布时间】:2014-01-21 13:00:55
【问题描述】:

我正在尝试将 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 上?我希望它在帖子中,所以如果我想更改图像,我只需编辑帖子即可。

【问题讨论】:

    标签: php html wordpress content-management-system custom-wordpress-pages


    【解决方案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...
    

    【讨论】:

      猜你喜欢
      • 2013-05-24
      • 1970-01-01
      • 1970-01-01
      • 2013-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-18
      • 1970-01-01
      相关资源
      最近更新 更多