Nicola Mustone

Happiness Lead @ Automattic



Cross-Post from a WordPress.com blog Automatically

Some weeks ago I started a new blog named When I Have Time where I write about anything not related to WordPress and WooCommerce.

It’s a WordPress.com blog, and I needed to boost it a bit. I thought to cross-post from that blog to this one, by creating posts here and linking them to that blog, but I didn’t want them to appear as real posts like others on this blog, more like referrals only.

I found some plugins to do this on the .org repository, but they didn’t do exactly what I wanted. So I decided to create mine.

WP.com Cross-Post

WP.com Cross-Post is a a free plugin that syncs your WordPress.com blog with your self-hosted WordPress site automatically, every day.

It creates posts on your self-hosted WordPress site by fetching them from WordPress.com through the API and publishes them automatically.

Since it simply copies posts, you may think that you could have problems with duplicated content and Google ranking. That’s true, but I introduced support for Yoast SEO. If you have it installed and active, WP.com Cross-Post will automatically insert a canonical link in the header pointing to the original blog post on WordPress.com so that Google knows that it is not the original post and will not consider it a duplicate.

Customization

This plugin is customizable via filters. The available filters are:

  • wpcom_crosspost_author_email: Pass the email address of the user to use as author of the cross-posts;
  • wpcom_crosspost_post_data: Filter the data before to create the cross-post;
  • wpcom_crosspost_sync_frequency: Change the frequency of the scheduled event to check for new posts;
  • wpcom_crosspost_api_call_params: Filter the data sent to WordPress.com via API to retrieve posts;
  • wpcom_crosspost_sinc_from: Change the “from” date to retrieve posts from WordPress.com. Default “yesterday”.

Configuration

Go to Settings > WP.com X-Post and fill in the Client ID and Secret. If you don’t have them, click on the button Create WordPress.com App to create an app on WordPress.com.

Save the changes. The button Connect to WordPress.com will appear. Click on it to connect your self-hosted site to WordPress.com and choose the blog you want to sync with.

One hour after the first activation there will be the first sync.

Cross-Post Design

The plugin does not include any style for cross-posts. They will look differently based on your theme’s style. If your theme supports post formats and has a specific style for the format link, that style will be used.

For Storefront, it does not include any special style for post formats, so the cross-posts were looking exactly like any other post. But, for my blog, I didn’t want that.

I just wanted a title for the cross-post, a category, and a link to the original post. So I created my post format template and style. If you need it too, here is what you need to do.

Link Post Format Style for Storefront

If you are not using one yet, create a child theme for Storefront, or download this starter child theme by Stuart Duff.

Before to upload it to your wp-content/themes/ folder, open it and create a file named content-link.php in the root of the child theme. Add this content inside of it:

Then, in the file style.css add this code:

That is all the code that you need to support the post format link in Storefront. This is how posts with that format will look:


Subscribe to This Blog

Receive new articles from this blog directly in your inbox! No spam guaranteed!

Join 670 other subscribers

Leave a Reply

You Might Also Like These Articles


Contribute to Improving This Blog

Did you enjoy this article? Was it helpful? Contribute to help me write more articles! The funds collected from this blog are reinvested directly into improving my skills or the blog so that I can provide more and better content!

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

€1.00
€5.00
€10.00
€5.00
€15.00
€100.00
€5.00
€15.00
€100.00

Or enter a custom amount


Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly

Don't Miss a Thing!

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 670 other subscribers

Continue Reading

Discover more from Nicola Mustone

Subscribe now to keep reading and get access to the full archive.

Continue reading