Use the_title_attribute() for the WHERE parameter in a page template
Answer provided by @Howdy_McGee who commented on the question. Using the prepare statement allowed the results to be pulled at the correct time and using %s is for strings and %d would be for a decimal or number value. $sql = $wpdb->prepare(“SELECT * FROM <databaseName>.<tableName> WHERE name=”%s””, get_the_title()); $results = $wpdb->get_results($sql, OBJECT);