2011-07-25 150 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