【发布时间】:2014-04-28 04:30:29
【问题描述】:
我有一个包含 2 个不同类别的相同 10 个帖子的列表....我需要一个单独的第 1 类和第 2 类永久链接...怎么做...
<?php
query_posts('cat=18');
if ( have_posts() ) while ( have_posts() ) : the_post();
$i++;
?>
<?php echo get_permalink(); ?><?php the_title();?> // comes with li and a
<?php
endwhile;
wp_reset_query();
?>
我通过相同的帖子有 2 个类别 17 和 18....第一次永久链接适用于第 18 类...重新加载后它适用于第 17 类的永久链接...我已经检查了 get_the_category() 它显示在 2 个数组数组 [0] 类别 17 和数组 [1] 类别 18... 所以它为第一个数组创建永久链接...但我需要第二个...
【问题讨论】:
-
嗨!你必须使用http://codex.wordpress.org/Function_Reference/get_categories。然后你可以通过那里自己的类别获得帖子。使用https://codex.wordpress.org/Template_Tags/get_posts。所以,你必须了解循环。 https://codex.wordpress.org/The_Loop。试试这些。这实际上是一个答案。在此之后,您仍然有疑问。我们可以清除这些。快乐编码。再见
-
我已经像上面那样做了...对于第 17 类和第 18 类相同的帖子...第一次为第 18 类创建永久链接...重新加载后它再次转到第 17 类永久链接跨度>
-
没有老板,使用这个LOOP。这很简单。如果你做了一些编码。请编辑您的问题并删除一些代码。
-
我已经更新了代码
标签: wordpress