error Incorrect usage/placement of 'SQL_CALC_FOUND_ROWS'
-
Hi,
I have a CPT named question and and connection named q_to_q which connects question to question.
In my home.php I would like to display some questions and their related questions.
When I try to use the function p2p_type I get a sql error to the errorlog.
(This is partial code, just with the p2p_type function usage, without looping it).
If I remvoe the p2p_type function – there are no errors.<?php $args = array( 'post_type' => 'question', 'posts_per_page' => 5, 'order' => 'DESC', ); $questions = new WP_Query($args); p2p_type( 'q_to_q' )->each_connected( $questions,array(),'ques_var' ); if ($questions->have_posts()) : while ($questions->have_posts()) : $questions->the_post(); ?> <article id="post-<?php the_ID(); ?>"> <h2><a href="<?php echo get_permalink($questions->post->ID) ?>"><?php echo get_the_title($questions->post->ID); ?></a></h2> </article> <?php endwhile; else : endif; ?>But when I just add the p2p_type function, this is what I get in the errorlog:
WordPress database error Incorrect usage/placement of 'SQL_CALC_FOUND_ROWS' for query SELECT tcmb_posts.*, tcmb_p2p.* FROM tcmb_posts INNER JOIN tcmb_p2p WHERE 1=1 AND tcmb_posts.post_type IN ('question') AND (tcmb_posts.post_status = 'publish' OR tcmb_posts.post_author = 1 AND tcmb_posts.post_status = 'private') AND (tcmb_p2p.p2p_type = 'q_to_q' AND (\n\t\t\t\t\t(tcmb_posts.ID = tcmb_p2p.p2p_to AND tcmb_p2p.p2p_from IN (SELECT SQL_CALC_FOUND_ROWS tcmb_posts.ID FROM tcmb_posts WHERE 1=1 AND tcmb_posts.ID IN (22) AND tcmb_posts.post_type IN ('question') AND (tcmb_posts.post_status = 'publish' OR tcmb_posts.post_author = 1 AND tcmb_posts.post_status = 'private') ORDER BY tcmb_posts.post_date DESC LIMIT 0, 1)) OR\n\t\t\t\t\t(tcmb_posts.ID = tcmb_p2p.p2p_from AND tcmb_p2p.p2p_to IN (SELECT SQL_CALC_FOUND_ROWS tcmb_posts.ID FROM tcmb_posts WHERE 1=1 AND tcmb_posts.ID IN (22) AND tcmb_posts.post_type IN ('question') AND (tcmb_posts.post_status = 'publish' OR tcmb_posts.post_author = 1 AND tcmb_posts.post_status = 'private') ORDER BY tcmb_posts.post_date DESC LIMIT 0, 1))\n\t\t\t\t)) ORDER BY tcmb_posts.post_date DESC made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/gisha_mediaproduct/home.php'), P2P_Connection_Type->each_connected, P2P_Directed_Connection_Type->get_connected, P2P_Directed_Connection_Type->abstract_query, P2P_Side_Post->do_query, WP_Query->__construct, WP_Query->query, WP_Query->get_posts, referer: http://gisha-qanda.local/question/22I already have another site using sort of the same logic, and it works, I just can’t figure out why I get this error here.
Maybe the error caused because the connection is between the same post type? (question to question)? I’d really appreciate your help solving this one, what am I missing here?
Thanks
The topic ‘error Incorrect usage/placement of 'SQL_CALC_FOUND_ROWS'’ is closed to new replies.