全球主机交流论坛

标题: wp如何通过【英文】TAG关键词调用相关文章?关键词是英文TAG [打印本页]

作者: leftgg    时间: 2019-11-24 11:44
标题: wp如何通过【英文】TAG关键词调用相关文章?关键词是英文TAG
wp如何通过【英文】TAG关键词调用相关文章?

关键词是英文TAG

  1. <ul>
  2. <?php
  3. $post_num = 10;
  4. global $post;
  5. $tmp_post = $post;
  6. $tags = ''; $i = 0;
  7. if ( get_the_tags( $post->ID ) ) {
  8. foreach ( get_the_tags( $post->ID ) as $tag ) $tags .= $tag->name . ',';
  9. $tags = strtr(rtrim($tags, ','), ' ', '-');
  10. $myposts =get_posts('numberposts='.$post_num.'&tag='.$tags.'&exclude='.$post->ID);
  11. foreach($myposts as $post) {
  12. setup_postdata($post);
  13. ?>
  14. <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
  15. <?php
  16. }
  17. }
  18. $post = $tmp_post; setup_postdata($post);
  19. ?>
  20. </ul>
复制代码

作者: leftgg    时间: 2019-11-24 14:47

作者: leftgg    时间: 2019-11-24 19:29

作者: leftgg    时间: 2019-11-24 21:09
技术类的没人回复吗??
作者: 怪人    时间: 2019-11-24 23:06
提示: 作者被禁止或删除 内容自动屏蔽
作者: 天有点热    时间: 2019-11-25 08:27
大部分主题都有tag.php这个页面,参考下别人怎么调用的




欢迎光临 全球主机交流论坛 (https://loc.mjj8.eu.org/) Powered by Discuz! X3.4