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:


/**
* Post format Link
*/
.hentry.type-post.format-link .entry-header {
margin-bottom: 5px;
}
.hentry.type-post.format-link .entry-title {
font-size: 1.618em !important;
}
.hentry.type-post.format-link .entry-title a::before {
content: "\f103";
position: relative;
display: inline-block;
margin-right: 7px;
font: normal 18px/1 dashicons;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
speak: none;
}
.hentry.type-post.format-link .entry-meta {
float: none;
width: 100%;
}
.hentry.type-post.format-link .entry-meta img {
display: inline-block;
margin-right: 20px;
vertical-align: middle;
}
.hentry.type-post.format-link .entry-meta .label {
font-weight: 400;
margin-right: 4px;
}

view raw

style.css

hosted with ❤ by GitHub

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:


More Posts That You Might Like…


Leave a Reply

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Blog at WordPress.com.

%d bloggers like this: