If your query has no dynamic input, then you technically do not need to use $wpdb->prepare()
, however that assumes your own input is safe.
If your query contains parameters in which are dynamic, especially supplied by users from a form as an example, then you will want to use $wpdb->prepare()
.
Using $wpdb->prepare()
is just good practice, but in order to use it, you must pass at least two arguments (the query, and at least one placeholder).
Please note: As of 3.5, wpdb::prepare() enforces a minimum of 2 arguments.
See: https://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/