2011-07-25 98 views
0

在这里有一些麻烦,我想要从帖子中获取所有图像并将它们显示在两个单独的位置,一个位置显示一个图像,第二个位置显示所有图像。WordPress获取页面图片

如果我使用查询,它会抓取所有帖子图片,并且使用查询时它会从页面抓取一张图片。关于如何从页面而不是帖子获取所有图像的任何想法?

<div id="fp_gallery" class="fp_gallery"> 
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
     <?php $args = array('numberposts' => 1, 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'post_parent' => 
     $post->ID); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { ?> 
      <img src="<?php echo wp_get_attachment_url($attachment->ID , false); ?>" alt="" class="fp_preview" style=""/> 
     <?php }}?> 
     <?php endwhile; endif; ?> 


      <div class="fp_overlay"></div> 
      <div id="fp_loading" class="fp_loading"></div> 
      <div id="fp_next" class="fp_next"></div> 
      <div id="fp_prev" class="fp_prev"></div> 

      <div id="outer_container"> 
       <div id="thumbScroller"> 
        <div class="container"> 
         <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
         <?php $args = array('numberposts' => 9999, 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'post_parent' => $post->ID); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { ?> 
          <div class="content"> 
           <div> 
            <a href="#" title="<?php the_title(); ?>"> 
             <img src="<?php echo get_bloginfo('template_url');?>/js/timthumb.php?src=<?php echo wp_get_attachment_url($attachment->ID , false); ?>&amp;h=120&amp;w=150&amp;zc=1" alt="<?php echo wp_get_attachment_url($attachment->ID , false); ?>" class="thumb"/> 
            </a> 
           </div> 
          </div> 
         <?php }}?> 
         <?php endwhile; endif; ?> 
        </div> 
       </div> 
      </div> 
    </div> 
    <div id="fp_thumbtoggle" class="fp_thumbtoggle" title="View Thumbs">&uarr;</div> 

任何帮助将是巨大的:)

回答

0

numberposts -1它将收集类别下

$args = array('numberposts' => 1, 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'post_mime_type' => 'image' ,'post_status' => null, 'post_parent' => 
     $post->ID); 

所有职位,但我不知道关于jQuery的事情,你说的关于。

+0

他说/写:>查询否jQuery。 – drmartin

+0

@DrMartin:你是什么意思。我希望,我给了OP正确的论点 – Gowri