I have a script that auto-creates posts from data provided, the main check that it does before creating a new post is to see if any post already exists with the title provided
$post_id = post_exists($title, '', '', 'cpt');
The problem is it fails with any post containing '&'. I have the incoming title wrapped in html_entity_decode before I pass it to wp_insert_post(), and even before formatting it with this, all of the incoming titles are using the '&' character and not any html entity or other format.
When I check in the wordpress database, the titles are also saved with the '&' symbol. But for some reason, the post_exists() check fails on all of them.
I'm kind of at a loss, any help would be greatly appreciated!
Edit: I've basically admitted defeat, I'm now just running str_replace('&', 'and', $title) on all my titles and that has resolved the issue.