2012-12-01 132 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

相关问题