gpt4 book ai didi

php - new WP_query() 和 query_posts() 之间的区别

转载 作者:行者123 更新时间:2023-12-02 01:10:34 25 4
gpt4 key购买 nike

关于效率的问题。使用 wp_query($args)$query = new WP_Query($args) 有什么区别?在效率/SQL 查询数量上有什么不同吗?一种总是比另一种更好,还是在某些情况下更喜欢一种风格?

例如,如果我想要一个基于类别的包含 3 列的复杂页面,那么以下两个示例有何不同?

$query = new WP_Query("category_name=Issue 1")
while ($query->have_posts())....

对比

rewind_posts()
query_posts("category_name=Issue 1")
while(have_posts())...

最佳答案

没有。

一个只是调用另一个,这是来自 WP source .

function query_posts($query) {
$GLOBALS['wp_query'] = new WP_Query();
return $GLOBALS['wp_query']->query($query);
}

天哪,我喜欢 WP,它太棒了。失败。

关于php - new WP_query() 和 query_posts() 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17999989/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com