WP-CLI Commands

Since version 3.8 my plugin Simple WordPress Crossposting comes with WP-CLI commands.

wp swc connect

This command allows to connect posts that already existed before you installed my plugin. Posts with the same slugs are going to be connected.

ArgumentDescription
[--id=<post-ID>]You can provide a specific post ID here. If not provided, the plugin will try to connect all published posts (of allowed post types).
[--site=<site-URL>]You can provide a site URL you would like to run this command for. By default – the first added website in the plugin settings.

Connect a post with ID=1328 to the website rudrastyh.com:

wp swc connect --id=1328 --site=rudrastyh.com
connect an existing post with the same slug with WP-CLI

Connect all posts to the first added site in the plugin settings:

wp swc connect
WP-CLI bulk connect posts

wp swc crosspost

ArgumentDescription
<post-ID>Provide a specific post ID here.
[--site=<site-URL>]You can provide a site URL you would like to run this command for. By default – the first added website in the plugin settings.

Crosspost (publish or update) a post with ID=5:

wp swc crosspost 5
Example of crossposting a post with WP-CLI command

This command currently doesn’t support the progress bar like wp swc connect, but you can try to combine it together with wp post list. For example this way we can crosspost all the pages:

for id in $(wp post list --post_type="page" --fields=ID )
do
	wp swc crosspost $id
done

Or for example you can crosspost WooCommerce products starting with the old ones:

for id in $(wp post list --post_type="product" --orderby="date" --order="ASC" --fields=ID )
do
	wp swc crosspost $id
done

I didn’t have a chance to test it for a large amount of posts, so please be careful.

Need more help?