Is it possible to create duplicate post on other site (either push, on publish, or pull, periodically)?

I have a requirement to add certain posts (marked with a tag or category) from "site a" to another site ("site b"). I think the best way would be for site b to periodically check site a for the presence of new posts in the category or with the keyword, but perhaps it would be better for site a to push select new posts to site b at time of publication.

The posts should look like they are locally stored posts, with featured images and full text search ability -- an RSS-feed-like list of the most recent posts isn't acceptable.

Thanks

Topic post-duplication plugin-development posts plugins Wordpress

Category Web


You could add a filter to the post publish process in site A. The filter would check for the tag/category, and if found, run a process to create a post in Site B.

See https://codex.wordpress.org/Plugin_API/Action_Reference/save_post . Something like:

add_action( 'save_post', 'my_site_b_create_post' );

function my_site_b_create_post($post_id) {
   // check for category
   // if category, then save content of site A post into variable (maybe title, author, etc)
   // create post on site B
   return;
}

Adding that hunk of code to the functions.php of Site A (in a Child Theme, of course, so a theme update doesn't bork your code).

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.