2012-03-23 67 views
1

你知道是否有任何插件或教程介绍了如何做到这一点?我会非常感谢任何帮助,因为我不擅长PHP。从wordpress图片库获取一张照片

我想在Wordpress页面上添加照片并将其作为标准图库粘贴到帖子内容中,然后我希望显示图库但是我感兴趣的是在该图库中获取一组照片并且然后遍历它。

这是干什么用的?我正在开发一个网站http://www.rasterbyte.com/,我想用这些图片作为背景幻灯片(按左/右键改变图片)。目前图像具有固定路径,我希望它们可以为每个页面定制。

非常感谢您的任何建议。

回答

0

嗨Maciek西姆,

我的理解你的问题,你在文章中的图片,你想在背景中显示。

您可以设置首页分类有5个帖子与特色图像。

混帐特定图像后

<?php $args = array(
    'width' => null, 
    'height' => null, 
    'css' => '', 
    'parent_id' => '', 
    'post_id' => '', 
    'filename' => '', 
    'return_html' => true  
); ?> 

more info

还要检查How to: Get the first image from the post and display it

function catch_that_image() { 
    global $post, $posts; 
    $first_img = ''; 
    ob_start(); 
    ob_end_clean(); 
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); 
    $first_img = $matches [1] [0]; 

    if(empty($first_img)){ //Defines a default image 
    $first_img = "/images/default.jpg"; 
    } 
    return $first_img; 
} 
相关问题