2012-12-01 133 views
0

我在WordPress中有這個插件,我已經大量修改過。插件的目的最初是爲了顯示您告訴它的任何類別的縮略圖。就目前而言,我已經完成了比這更多的工作。但無論如何,這裏是插件的簡碼..在Wordpress中按標籤顯示帖子

[categorythumbnaillist 7] 

7是類別ID當然。該插件獲得使用此代碼對任何類別的職位和命令他們:

$myposts = get_posts('numberposts=-1&&category='.$listCatId[1].'&&orderby= 
'.$categoryThumbnailList_OrderType.'&&order='.$categoryThumbnailList_Order); 

現在,我想要的插件,只顯示帖子,如果有在它的標籤「新聞」。所以我做了以下工作:

$args=array(
      'tag' => 'news', 
      'showposts'=>5, 
     ); 
$myposts = get_posts($args); 

如果它有「news」標籤,它會顯示5個帖子。 但這裏是問題 ...

我打算在一個頁面上多次使用這個插件。因此,當我使用上面列出的短代碼和不同的類別ID時,插件不起作用,因爲我沒有將短代碼類別ID與$ myposts代碼鏈接起來。 :(

我將使用插件與我的新聞類別,照片類別和音頻類別。我希望它通過短代碼顯示每個類別的縮略圖(就像插件打算這樣做),但也只顯示只有新聞類別的標籤爲「新聞」...的新聞帖子,如何合併我的兩個代碼以使其正常運行,並且只顯示標籤爲「新聞」的新聞帖子,同時仍然正確顯示其他類別帖子。 ..所有通過類似插件簡碼應該怎麼辦?因此,舉例來說......我不得不..

[categorythumbnaillist 3] (news category) 
[categorythumbnaillist 5] (photos category) 
[categorythumbnaillist 7] (audio category) 

我想消息只與標籤「新聞」顯示新聞信息,照片顯示照片類別帖子和音頻播放音頻類別的帖子。再說一遍,我已經想出瞭如何做這個或那個,我只是不知道如何讓代碼都做。

任何幫助將真正被讚賞! :)

回答

0

請使用下面的代碼或插件

<?php 
$postslist = get_posts('numberposts=5&orderby=date&tag=heresthetag'); 
foreach ($postslist as $post) : 
    setup_postdata($post); 
?> 

<?php $the_image = get_image(); ?> 
    <div class="newspage" <?php if($the_image != "") { ?> style="min-height:5.00em;" <?php } ?>> 
<?php if($the_image != "") {?> 
     <div class="newspage-img"><a href="<?php the_permalink() ?>"><?php echo $the_image; ?></a> 
     </div> 
      <div class="newspage-content"><?php } else {?><div class="newspage-content" style="padding-left:0;"><?php }?> 
      <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Continue reading <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3> 
       <div class="entry"> 
       <?php the_excerpt() ?> 
       <p><span class="read_more"><a href="<?php the_permalink(); ?>">Read more...</a></span> <span class="feedback"><?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?></span></p> 
       </div> 
      </div> 
    </div> 
<?php endforeach; ?> 

插件 - http://wordpress.org/extend/plugins/posts-by-tag/

+0

很顯然,你沒有閱讀我的文章...這無關我的問題都沒有。你只是回答了我的帖子的標題,而不是真正的問題......我問的是如何組合上面列出的兩個代碼,而不僅僅是通過標籤發佈...... – user1658560

相關問題