【问题标题】:Wordpress: Remove links from list of posts gathered by a categoryWordpress:从按类别收集的帖子列表中删除链接
【发布时间】:2013-11-24 03:22:50
【问题描述】:

我有属于某个类别的帖子的链接列表。该列表显示在帖子上。生成列表的代码如下:

<?php 
$sel_works = new WP_Query('category_name=Selected_Works&showposts=-1'); while($sel_works->have_posts()) : $sel_works->the_post(); 
?>
<a href="<?php the_permalink() ;?>"><?php the_title(); ?></a><span class="CatSep"> / </span></li>
<?php endwhile; ?>

我想知道是否有办法删除列表中指向我们已经发布的帖子的链接。我很难定义条件,非常感谢您的帮助。

【问题讨论】:

    标签: php regex wordpress-theming wordpress


    【解决方案1】:
    <?php
    $current_id = get_the_ID();
    $query_settings = array(
        'category_name'=>'Selected_Works',
        'posts_per_page'=>-1,
        'post__not_in'=>array($current_id)
    );
    $sel_works = new WP_Query($query_settings);
    while($sel_works->have_posts()) : $sel_works->the_post(); 
    ?>
    <a href="<?php the_permalink() ;?>"><?php the_title(); ?></a><span class="CatSep"> / </span></li>
    <?php endwhile; ?>
    

    【讨论】:

      猜你喜欢
      • 2013-09-21
      • 1970-01-01
      • 1970-01-01
      • 2017-01-08
      • 2013-10-29
      • 1970-01-01
      • 1970-01-01
      • 2013-10-21
      • 1970-01-01
      相关资源
      最近更新 更多