Using meta_key
and meta_value
are good for filtering a single custom field. But for comparing two fields, you need to construct a meta_query
with your two key/values and a compare
operator.
See this answer which shows the various things you need to do to achieve this.