在当前帖子的开头显示具有特定标签的帖子标题列表

时间:2014-10-23 06:23:39

标签: php wordpress shortcode

我希望,可能是短代码,如果为当前帖子选择了此选项,则会显示在此帖子之前发布的所有具有特定标签的帖子的当前帖子列表的开头。此外,在帖子的最后应该放置我将来使用该标记发布的所有帖子。可能吗? :)

<li>Title of first post with specific tag</li>
<li>Title of second post with specific tag</li>
.
.
.
<li class="current-post">This post title</li>

<li>Title of fourth post with specific tag</li>
<li>Title of fifth post with specific tag</li>
.
.
.



谢谢!

1 个答案:

答案 0 :(得分:-1)

    <?php

//Starting loop getting post of custom post type
  while ($custom_query->have_posts()) : $custom_query->the_post();
    $title=get_the_title($post->ID);
    ?>
        <!-- The code print the title of post and link on it -->
    <li><a title="<?php echo $title; ?>"href="<?php the_permalink(post->ID);?>"><?php echo $title; ?></a></li>
    <?php endwhile; ?>

//end loop