How to know if get_posts() failed?
Here’s one way to check if there was an DB error within get_posts(): global $EZSQL_ERROR; $before = isset( $EZSQL_ERROR ) ? count( $EZSQL_ERROR ) : 0; $posts = get_posts( $args ); $after = isset( $EZSQL_ERROR ) ? count( $EZSQL_ERROR ) : 0; if ( empty( $posts ) && $before < $after ) { // … … Read more