WordPress 类别
我正在创建一个由两个页面组成的主题,博客和作品集。因此,我有与投资组合帖子相关的类别(即网页设计、图形设计)和与博客帖子相关的类别(即教程、待办事项)
我有两个页面(/blog和/portfolio),在每个页面中,我会喜欢显示与特定类型相关的类别列表
(我可能不清楚),所以这是一个示例:
所有类别:cat1,cat2,cat3,cat4,cat5,cat6
for portfolio:
<ul>
<li><a>cat1</a></li>
<li><a>cat2</a></li>
<li><a>cat3</a></li>
</ul>
for blog:
<ul>
<li><a>cat4</a></li>
<li><a>cat5</a></li>
<li><a>cat6</a></li>
</ul>
所以有没有办法像这样分割它们
谢谢
i am creating a theme which consists of two pages, blog and portfolio. therefore i have categories which related to the portfolio posts (ie. web design, graphic design) and categories relating to the blog posts (ie. tutorials, todos)
i have two pages (/blog and /portfolio), in each, i would like to show the list of categories related on to the specific types
(i may not be clear) so this is an example:
all categories: cat1, cat2, cat3, cat4, cat5,cat6
for portfolio:
<ul>
<li><a>cat1</a></li>
<li><a>cat2</a></li>
<li><a>cat3</a></li>
</ul>
for blog:
<ul>
<li><a>cat4</a></li>
<li><a>cat5</a></li>
<li><a>cat6</a></li>
</ul>
so is there a way to split them like that
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在模板中使用 wp_list_categories() 方法,该方法采用“exclude”或“exclude_tree”参数,允许您排除第一个列表中的博客类别和第二个列表中的投资组合。
http://codex.wordpress.org/Template_Tags/wp_list_categories
You can use wp_list_categories() method in your template, this method takes an "exclude" or "exclude_tree" parameter, which allows you to exclude blog categories in the first list, and portfolio in the second.
http://codex.wordpress.org/Template_Tags/wp_list_categories
这是我用来控制在 WordPress 博客的哪些页面上显示哪个类别的帖子的方法。我将这行代码插入到 page.php 文件中,就在调用循环之前:
注意:“is_page=”后面括号中的名称是页面slugs,不是页面标题。
使用这行代码,您可以知道哪个页面显示哪个类别的帖子。
如果需要,您可以在我的博客上阅读有关此内容的更多信息:WordPress:如何控制特定页面上显示的帖子类别
Here is the method I use to control which category of posts shows on which pages of a WordPress blog. I insert this line of code into the page.php file, just before the loop is called:
Note: The names in parentheses after "is_page=" are the page slugs, not the page titles.
Using this line of code, you can tell which page to display which category of posts.
You can read more info about this at my blog if you need it: WordPress: How to control which category of posts displays on particular pages