WordPress 4.8.2 specifically restricts the convenient usage of numbered placeholders like %1$s
, %1$d
, %1%f
in WPDB::prepare
. (core.trac.wordpress.org/ticket/41925).
To avoid usage of numbered placeholders, SQL query has to be rearranged to just use only one %s
.
SELECT DISTINCT t.`Date`, y.*
FROM `table` t
LEFT JOIN `table` y ON (t.`Date` = y.`Date`)
WHERE t.`country` = %s
ORDER BY t.`Date` DESC
LIMIT 1