post_exists() in an external script?

post_exists() doesn’t exist because you forgot to include the file where the function is declared. Looking to https://developer.wordpress.org/reference/functions/post_exists/#source you can see that it’s declared in wp-admin/includes/post.php

Add this to your existing code juste after the require of taxonomy.

require_once ABSPATH . '/wp-admin/includes/post.php';

The best way to achieve what you want is to use wp-api in my opinion !

Leave a Comment