I'm using wp_query to search a string:

$args = array('s' => '2nd','posts_per_page' => '-1',);

I'm looking for the 2nd of the month but it is also returning 22nd which is pragmatically correct, but logically incorrect as I only want the 2nd day and not all instances of a string w the word '2nd' in it (which is why '22nd' is included).

The word "2nd" is part of a paragraph so I don't think you can use

$args = array('day' => '2nd','posts_per_page' => '-1',);

because the instance of the word "2nd" isn't a date. It's in a paragraph as part of a string.

So is there a way to search on "2nd" and not return "22nd"?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.