简体   繁体   English

我想用两个类别对我的WordPress主题中的帖子进行排序

[英]I want to sort my posts in my wordpress theme with two categories

I am creating a wordpress theme, and as a beginner, I am having difficulties. 我正在创建一个wordpress主题,作为一个初学者,我遇到了困难。 The website will be a products portfolio, but not e commerce. 该网站将是产品组合,而不是电子商务。 It has a main menu of categories, and another menu on the sidebar with categories. 它具有类别的主菜单,以及带有类别的侧栏上的另一个菜单。 The posts will be sorted by two categories. 帖子将按两个类别进行排序。 First of all, by the main category in the header, and then, those posts will be sorted by the other categories in the sidebar. 首先,按标题中的主要类别,然后,这些帖子将按侧边栏中的其他类别进行排序。 I have no idea how to do this. 我不知道该怎么做。 Tried a lot to think of something, but I can't come up with anything. 想了很多事情,但我什么都做不了。 I hope you can help me how to sort it out. 希望您能帮我解决问题。

I had an idea to use TAGS as sidebar categories, but I couldn't get it to work. 我有一个想法可以将TAGS用作侧边栏类别,但无法正常使用。

Thanks. 谢谢。

Take a look at wp_nav_menu() 看看wp_nav_menu()

The wordpress backend has a menu making system where you can make menus based on pages/posts/categories. WordPress后端具有菜单制作系统,您可以在其中基于页面/帖子/类别进行菜单。 These menu items will take you to a page with a list of all the posts existing in those categories. 这些菜单项将带您进入一个页面,其中列出了这些类别中现有的所有帖子。

So: 所以:

  1. make your categories 做你的类别
  2. go to the menu maker 去菜单制作者
  3. create the 1st menu and assign categories 创建第一个菜单并分配类别
  4. create your 2nd menu and assign categories 创建第二个菜单并分配类别

Use wp_nav_menu() to pull the specific menu in. The docs that I linked give you a good overview of how to get the menu you want. 使用wp_nav_menu()可以wp_nav_menu()定菜单。我链接的文档为您提供了有关如何获取所需菜单的良好概述。

You will have to style these menus appropriately. 您将必须适当地设置这些菜单的样式。

Good luck and happy coding! 祝您好运,编码愉快! If you have any specific questions, feel free to ask and I can expand on it further. 如果您有任何具体问题,请随时提出,我可以进一步扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM