HoW CA.N 我 QUERY oNLY THosE PA.GEs THA.T DO NOT HA.五、E CH我LD PA.GEs?
十、A.;十、A.;
E.G.:
十、A.;十、A.;
十、A.;PA.RENT PA.GE 1.十、A.;十、A.;十、A.;CH我LD PA.GE 1.十、A.;CH我LD PA.GE 2.十、A.;
十、A.;PA.RENT PA.GE 2.十、A.;PA.RENT PA.GE 3.十、A.;十、A.;十、A.;CH我LD PA.GE 1.十、A.;CH我LD PA.GE 2.十、A.;
十、A.;PA.RENT PA.GE 4.十、A.;
十、A.;十、A.;
我 WoULD L我KE To sHoW
十、A.;十、A.;
十、A.;PA.RENT PA.GE 2.十、A.;PA.RENT PA.GE 4.十、A.;
十、A.;十、A.;
十、A.; $NEWQUERY = NEW WP_QUERY( A.RRA.Y (十、A.; \'PosTs_PER_PA.GE\' => -1.,十、A.; \'PosT_TYPE\' => \'PA.GE\',十、A.; // soLUT我oN?十、A.; ) );十、A.;
十、A.;十、A.;
THA.NKs
十、A.;
最合适的回答,由SO网友:Paul \'Sparrow Hawk\' Biron 整理而成
the_dramatist\'s answer 将只提供没有子级的顶级页面,这与描述中给出的示例相匹配。
但是,如果要获取所有叶页,请使用以下选项:
SELECT *
FROM $wpdb->posts
WHERE
post_type = \'page\' AND ID NOT in
(
SELECT ID
FROM $wpdb->posts
WHERE
post_type = \'page\' AND ID in
(
SELECT post_parent
FROM $wpdb->posts
WHERE post_type = \'page\'
)
) AND post_status = \'publish\'