admin管理员组文章数量:1389750
Has anyone encountered a DB error when using pre_get_posts to display ALL posts on a CPT archive page?
This error...
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1]
SELECT SQL_CALC_FOUND_ROWS dfr34_wp_posts.ID FROM dfr34_wp_posts WHERE 1=1 AND dfr34_wp_posts.post_type = 'our-work' AND (dfr34_wp_posts.post_status = 'publish' OR dfr34_wp_posts.post_status = 'acf-disabled' OR dfr34_wp_posts.post_status = 'private') ORDER BY dfr34_wp_posts.post_date DESC LIMIT 0, -1
I'm using the following code and the error only shows if i try and show all posts, if i just put a number in it works.
function work_query_order($query){
if( ! is_admin() && is_post_type_archive( 'our-work') && $query->is_main_query() ):
$query->set( 'posts_per_page', -1);
endif;
};
add_action( 'pre_get_posts', 'work_query_order', 5 );
本文标签: databasepregetposts causings DB error when using ( 39postsperpage391)
版权声明:本文标题:database - pre_get_posts causings DB error when using ( 'posts_per_page', -1)? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744672549a2618911.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论