如何获取分类 post link 并显示

How to get taxonomy post link and display

我创建了这个循环来获取最后添加的分类类别 posts.Here 是代码

 $issue = get_terms('articles-tax','orderby=Desc&order=ASC');
 $latest_edition = $issue[0]->slug;
 $latest_edition = $issue[0]->term_id;
 $postsart = get_posts(array(
 'showposts' => -1,
 'post_type' => 'articles',
 'tax_query' => array(
  array(
 'taxonomy' => 'articles-tax',
 'field' => 'term_id',
 'terms' => $latest_edition)
)) );        foreach ($postsart as $mypost) { ?>
 <div class="article_item"><div class="article_title"><?php echo $mypost->post_title?></div><div class="article_short_content"> <?php  echo $mypost->post_excerpt ?> </div>
        <div class="news_border"></div>
        <div class="news_readmore"><a href="<?php  ?>">Read More</a></div>
             </div>

所以现在我无法获得 post 的永久链接,不知道如何从 array.Had 完成 var_dump 的 $mypost,但无法管理如何获得一件商品 permalink.Help 我来解决这个问题!

使用

 $permalink = get_permalink($mypost->ID);
 echo $permalink ;

它将为您提供帖子的永久链接

在代码中添加 "global post" 函数似乎可以解决问题

像这样:

$postsart = get_posts(array(
 'showposts' => -1,
 'post_type' => 'articles',
 'tax_query' => array(
  array(
 'taxonomy' => 'articles-tax',
 'field' => 'term_id',
 'terms' => $latest_edition)
)) );   
global $post;
foreach ($postsart as $post) { 
setup_postdata($post);
?>
 <div class="article_item"><div class="article_title"><?php echo $post->post_title?></div><div class="article_short_content"> <?php  echo $post->post_excerpt ?> </div>
        <div class="news_border"></div>
        <div class="news_readmore"><a href="<?php echo get_the_permalink($post->ID);  ?>">Read More</a></div>
             </div>