I'm trying to use get_posts( $args ) to get some custom post types. Is there a way to see the mysql query generated by the get_posts function?
Thank you to Tom J Nowell for pointing me to using
WP_Query instead of
get_posts. With WP_Query you have the entire
WP_Query object to reference. So something like the following gives the actual mysql query of the args I was using.
// these same args also worked with get_posts() $args = array( 'post_type' => 'post', 'order' => 'ASC', 'post_status' => 'publish', ); // create a new WP_Query object with the args above $the_object = new WP_Query($args); // show the mysql as a string echo $the_object->request; // see EVERYTHING in the WP_Query object var_dump($the_object);