Wordpress:从单亲页面呼叫所有孩子的孙子

发布于 2024-12-28 01:35:01 字数 398 浏览 2 评论 0原文

嗯嗯是的。

我正在开发一个 Wordpress 电子商务网站。想要有一个名为“商店”的顶级父页面,其子页面为:“产品类型 1”、“产品类型 2”、“产品类型 3”。

三个二级子页面中的每一个都会有一长串产品列表(作为第三级子页面) 这是我的问题:选择顶级

“商店”页面时,我想查询所有孙子页面,我还想从列表中排除第二级子页面......这些页面仅作为模板存在。出于搜索引擎优化的原因

。我过去在调用子页面时使用过:

query_posts("post_parent=48&post_type=page&orderby=title&order=asc");

其中 post_parent=48 是顶级页面的 ID 有什么建议吗?

Ummmm yeaaah.

I'm working on a Wordpress eCommerce site. Want to have a top level parent page called "Shop" with Child pages: "Product Type 1", "Product Type 2", Product Type 3".

Each of the three second level children will have a long list of products (as third level children).

Here is my issue: When the top level "Shop" page is selected, I want to query ALL of the grandchildren. I also want to exclude the second level children from the list...those pages only exist as templates and for SEO reasons.

Here is what I've used in the past when calling child pages:

query_posts("post_parent=48&post_type=page&orderby=title&order=asc");

Where post_parent=48 is the top level page's ID. Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

并安 2025-01-04 01:35:01

这就是我最终为此所做的,非常适合我的情况:

if ( (is_page('Shop')) or (is_page('Product Type 1')) ) {

query_posts("showposts=100&post_parent=34&post_type=page&orderby=title&order=asc");

while(have_posts()) {

the_post(); // vital 

其中 post_parent=34 是产品类型 1 的帖子 ID。然后:

wp_reset_query(); 

if ( (is_page('Shop')) or (is_page('Product Type 2')) ) {

query_posts("showposts=100&post_parent=48&post_type=page&orderby=title&order=asc");

while(have_posts()) {

the_post(); // vital 

其中 post_parent=48 是产品类型 2 的帖子 ID...依此类推所有产品类型。

不确定这是否是设置此功能的最佳方式,但非常简单并且......它有效;)

This is what i ended up doing for this, works great for my situation:

if ( (is_page('Shop')) or (is_page('Product Type 1')) ) {

query_posts("showposts=100&post_parent=34&post_type=page&orderby=title&order=asc");

while(have_posts()) {

the_post(); // vital 

Where post_parent=34 is the post ID of Product Type 1. Then:

wp_reset_query(); 

if ( (is_page('Shop')) or (is_page('Product Type 2')) ) {

query_posts("showposts=100&post_parent=48&post_type=page&orderby=title&order=asc");

while(have_posts()) {

the_post(); // vital 

Where post_parent=48 is the post ID of Product Type 2...And so forth for all Product Types.

Not sure if this is the Best way of setting this up, but was pretty simple and...it works ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文