开发者

Wordpress SQL query: get random child page

I want my site to have a random "welcome" page.

I've found a plugin that redirects to a random page. I want to specify a parent page that random child pages are selected from.

This is the query that the plug-in uses:

$query = "SELECT ID FROM $wpdb-&g开发者_如何学运维t;posts WHERE post_type = 'page' AND post_password = '' AND post_status = 'publish' ORDER BY RAND() LIMIT 1";

How would I get it to return a random child page from a specific parent page?

Thanks for looking.


So simple I missed it. Just add AND post_parent='42' where 42 is your parent's ID.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜