admin管理员组文章数量:1130349
Assume the following custom taxonomy structure:
- USA
- California
- Los Angeles
- San Francisco
- Oakland
- New York
- New York
- Buffalo
- Rochester
- California
Note: It's just sample data, so don't bother to correct it!
Now, assume the following custom post type data:
- Some posts will be country-wide, so they will only be assigned to the USA category.
- Some posts will only be valid in certain states, so they will get assigned only those categories, eg. California or New York.
- Some posts will only be valid in certain cities, so they will get assigned only to those categories, eg. Los Angeles or Rochester.
I want to configure WordPress such that:
- If I browse to a top-level category (eg. USA), it should show a list of posts that belong to USA as well as every descendant, eg. California, Los Angeles, New York, Rochester, etc., i.e. the whole country.
- If I browse to a mid-level category (eg. California), it should show the obvious list of posts belonging to that category as well as all descendants, i.e. California, Los Angeles, San Fransisco, Oakland, etc., but it should also show me all posts that are tagged with the top level, i.e. USA.
- If I browse to the last level category page, (eg. Buffalo), it should show me posts in Buffalo, it's parent, New York and it's grandparent, USA as well.
Is this something that can be configured from within the custom post type and/or taxonomy configuration or will it need modification of the loop? What exactly would I need to do to achieve this?
Assume the following custom taxonomy structure:
- USA
- California
- Los Angeles
- San Francisco
- Oakland
- New York
- New York
- Buffalo
- Rochester
- California
Note: It's just sample data, so don't bother to correct it!
Now, assume the following custom post type data:
- Some posts will be country-wide, so they will only be assigned to the USA category.
- Some posts will only be valid in certain states, so they will get assigned only those categories, eg. California or New York.
- Some posts will only be valid in certain cities, so they will get assigned only to those categories, eg. Los Angeles or Rochester.
I want to configure WordPress such that:
- If I browse to a top-level category (eg. USA), it should show a list of posts that belong to USA as well as every descendant, eg. California, Los Angeles, New York, Rochester, etc., i.e. the whole country.
- If I browse to a mid-level category (eg. California), it should show the obvious list of posts belonging to that category as well as all descendants, i.e. California, Los Angeles, San Fransisco, Oakland, etc., but it should also show me all posts that are tagged with the top level, i.e. USA.
- If I browse to the last level category page, (eg. Buffalo), it should show me posts in Buffalo, it's parent, New York and it's grandparent, USA as well.
Is this something that can be configured from within the custom post type and/or taxonomy configuration or will it need modification of the loop? What exactly would I need to do to achieve this?
Share Improve this question asked Dec 17, 2018 at 10:57 aalaapaalaap 7541 gold badge8 silver badges18 bronze badges1 Answer
Reset to default 1Use wp_list_categories with the taxonomy argument, it is built to create hierarchal category lists but it will also support using a custom taxonomy.
Example:
Display hierarchal categories
using this you can see their hierarchal structure.
let me know the result
Assume the following custom taxonomy structure:
- USA
- California
- Los Angeles
- San Francisco
- Oakland
- New York
- New York
- Buffalo
- Rochester
- California
Note: It's just sample data, so don't bother to correct it!
Now, assume the following custom post type data:
- Some posts will be country-wide, so they will only be assigned to the USA category.
- Some posts will only be valid in certain states, so they will get assigned only those categories, eg. California or New York.
- Some posts will only be valid in certain cities, so they will get assigned only to those categories, eg. Los Angeles or Rochester.
I want to configure WordPress such that:
- If I browse to a top-level category (eg. USA), it should show a list of posts that belong to USA as well as every descendant, eg. California, Los Angeles, New York, Rochester, etc., i.e. the whole country.
- If I browse to a mid-level category (eg. California), it should show the obvious list of posts belonging to that category as well as all descendants, i.e. California, Los Angeles, San Fransisco, Oakland, etc., but it should also show me all posts that are tagged with the top level, i.e. USA.
- If I browse to the last level category page, (eg. Buffalo), it should show me posts in Buffalo, it's parent, New York and it's grandparent, USA as well.
Is this something that can be configured from within the custom post type and/or taxonomy configuration or will it need modification of the loop? What exactly would I need to do to achieve this?
Assume the following custom taxonomy structure:
- USA
- California
- Los Angeles
- San Francisco
- Oakland
- New York
- New York
- Buffalo
- Rochester
- California
Note: It's just sample data, so don't bother to correct it!
Now, assume the following custom post type data:
- Some posts will be country-wide, so they will only be assigned to the USA category.
- Some posts will only be valid in certain states, so they will get assigned only those categories, eg. California or New York.
- Some posts will only be valid in certain cities, so they will get assigned only to those categories, eg. Los Angeles or Rochester.
I want to configure WordPress such that:
- If I browse to a top-level category (eg. USA), it should show a list of posts that belong to USA as well as every descendant, eg. California, Los Angeles, New York, Rochester, etc., i.e. the whole country.
- If I browse to a mid-level category (eg. California), it should show the obvious list of posts belonging to that category as well as all descendants, i.e. California, Los Angeles, San Fransisco, Oakland, etc., but it should also show me all posts that are tagged with the top level, i.e. USA.
- If I browse to the last level category page, (eg. Buffalo), it should show me posts in Buffalo, it's parent, New York and it's grandparent, USA as well.
Is this something that can be configured from within the custom post type and/or taxonomy configuration or will it need modification of the loop? What exactly would I need to do to achieve this?
Share Improve this question asked Dec 17, 2018 at 10:57 aalaapaalaap 7541 gold badge8 silver badges18 bronze badges1 Answer
Reset to default 1Use wp_list_categories with the taxonomy argument, it is built to create hierarchal category lists but it will also support using a custom taxonomy.
Example:
Display hierarchal categories
using this you can see their hierarchal structure.
let me know the result
本文标签: loopHow do I display a list of posts under all hierarchical children of the current taxonomy
版权声明:本文标题:loop - How do I display a list of posts under all hierarchical children of the current taxonomy? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749091489a2314588.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论