Given a site with 100 posts, where an unspecified number of posts are manually written, and the rest are created using the WordPress importer, how would I programmatically identify the posts imported without having access to remote sites or the original import file?
E.g. was this post created by the Importer tool?
Two things I could imagine:
post_modified
value. Maybe import creates a definitive timestamp that you could use. You’ll still have to save the import date somewhere so you can check against it.'import_allow_create_users'
with simply setting a callback of__return_false
.'import_post_meta'
.In case you’re infiltrating the native importer plugin, you’d need to start at the
'import_start'
hook. The last hook in the system (where you might want to check if everything went fine), is the'import_end'
hook.EDIT
I just encountered a class that I’ve not even known that it exists (in core, not the WP Importer plugin):
WP_Importer
. This class has a method, namedget_imported_posts()
.So in theory you could do the following:
The meta key that gets searched for is built by the two meta keys:
So there seems to be a unique trace route that one can follow.
Update #2
An example query you could run would be:
This should bring all similar posts up an allow you to determine the “importer_name” easier.
Edit #3
There’s
get_importers()
, which you can dump to see what importers are registered (usingregister_importer()
). This should help identifying the actual importer name.While I am not aware of import doing anything explicit to mark the posts, the possible indicators are:
guid
field, if posts weren’t imported from same domain (or some other differentiation)post_id
field, which is suggested byimport_id
during import and can result in possibly detectable block of IDs that are not sequential to natively created ones