i have 2 wordpress websites A
and B
.
if A
somehow changes (adding a post , editing a post , deleting a post ) , B needs to change as well .
so in A
by using a php robot which is checking database every couple of minutes , i,ve created a json feed for added
and edited
posts of A
.
it's easy to track added/edited posts by checking wp_posts
table . but i can't find a way to know which posts have been deleted ( Delete Permanently ).
this script is suppose to be portable and usable for people who are not programmer , so i dont want to use wordpress functions or do any change/addition to wordpress system .
so is there any way to find deleted posts by checking the database or something like that ?
You can check for posts in the trash by using the query:
SELECT * FROM `wp_posts` WHERE `post_status` = 'trash'
but if you are trying to find posts that have been removed from the database you will need to either track the missing IDs in the wp_posts
table or add some functionality to track when a post is deleted. You can do this by using the delete_post
action hook in your theme:
function my_tracking_function() {
// Put ID into new database table
}
add_action( 'delete_post', 'my_tracking_function', 1 );
And then pass that table to the other site for processing. Once both sites are synced you can run a cleanup routine to empty the tracking table. I realize that this is partially using Wordpress functionality, but the passing of the table data can be done outside of Wordpress using SQL.