2011-10-14 36 views
0

即時通訊這個功能,我做了一些麻煩。我的問題是,當查詢('showposts = 1');是設置特色的帖子不拾起。但是當我把查詢(''); sharethis插件不起作用。任何人都可以幫助我解決我可能做錯的事情。WordPress精選文章和sharethis問題

<div id="block_feature"> 
    <div id="featured_post" class="post"> 
     <div class="post_inner"> 

      <?php 
      $featured = new WP_Query(); 
      $featured->query('showposts=1'); 
      while($featured->have_posts()) : $featured->the_post(); 

      //$wp_query->in_the_loop = true; // This line is added so that the_tags('') will work outside the regular loop. 
      $featured_ID = $post->ID; // We'll store this here so that we know to skip this post in the main loop 
      ?> 

       <?php if(get_post_meta($post -> ID, 'feature', true)) { ?> 


        <?php if (get_post_meta($post->ID, 'large_preview', true)) { ?> 
         <div class="post_image"> 
         <img src="<?php echo get_post_meta($post->ID,'large_preview',true);?>" width=150px; height=150px alt="Featured Post"/> 
         </div> 
        <?php } ?> 

         <div class="excerpt"> 
         <h2><a href="<?php the_permalink();?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> 
         <small>on <?php the_time('M d'); ?> in <?php the_category(',');?> tagged <?php the_tags(''); ?></small> 
         <?php the_excerpt();?> 
         </div> 
         <a href="<?php the_permalink(); ?>" class="readMore">Read More</a> 


       <?php } ?> 
      <?php endwhile; ?> 
     </div>       
    </div>     
</div> 

回答

1

showposts因爲2.1版本被棄用,因此它可能是更好地使用posts_per_page代替。不知道它是否會有所作爲,但你也可以用$featured = new WP_Query('showposts=1');

替換PHP的前兩行。至於什麼導致的問題我不確定,你的查詢看起來對我很好,你沒有提到以什麼方式共享這失敗了。我對Share This插件並不熟悉,但大多數插件使用附加到the_content篩選器的篩選器函數將其內容添加到帖子中。也就是說,這可能只是因爲您使用the_excerpt()而不是the_content()