Custom Fields are Empty after Crossposting

You need to configure the plugin. Please go to “Settings > Crosspost”, then “Metadata” tab and copy and paste the code snippet to all the websites you’re going to crosspost to.

Even if you are not planning to use custom fields, so many plugins rely on them. If a crossposted post doesn’t look the way it should, make sure metadata is configured.

Unfortunately the metadata should always be configured this way and there is no other simpler way of doing that, it is just how WordPress REST API works by design.

Explained in details on this video:

Custom fields for ACF (Advanced Custom Fields)

This part is easy as pie, for custom fields created with the ACF plugin all you need to do is to install and activate an add-on for ACF from this page (and make sure that your custom fields are allowed for REST API in settings) that’s all.

No extra configuration needed.

Custom fields for Custom Post Types

If you’ve configured everything perfectly but you still don’t see the values of custom fields on subsite(s) and those are the custom fields for a custom post type, then probably there is one more thing to check.

When registering a custom post type please make sure custom-fields flag is included in supports parameter. Especially on subsite(s) where you about to crosspost to.

When registering a custom post type in code:

register_post_type(
	'articles',
	array(
		
		...
		
		'supports' => array( 'title', 'editor', 'custom-fields' )
	)
);

When using CPT UI plugin:

CPT UI custom fields support

When using Pods plugin (edit pod and then switch to Advanced Options tab).

configure custom post type in Pods plugin
Do not worry about what they are saying about slow performance. If you care about site performance, you’d better register custom post types in functions.php

How to Fix a Custom Field Error?

Ok, but what to do if you’ve done everything mentioned in this guide but still getting an error like that?

WordPress REST API custom field error
This error may appear in both Block Editor and Classic Editor.

First of all there is an easy way to fix that error – you can just exclude this specific custom field from syncing:

Exclude a specific meta key from syncing

But if it is important for you to crosspost the value of that custom field, please read below.

Check for Inconsistent Values in the Database

This error usually happens when a specific meta field is incorrectly configured in the snippet we inserted into the second site before. Why the plugin provided you with the incorrect metadata config? I am sorry to bring it to you but there is a mess in your database. I will explain.

For example you’ve created a specific custom field on your website and decided that its value will be an object just like that:

meta value of an object type
We have a serialized object as a custom field value here.

But then you changed your mind and decided – why to not simplify the whole thing a little bit and make the field a simple text string instead? It resulted to the inconsistency in the database:

different types of meta values at the same time
The custom field with the same “meta_key” has values of different types!

But my plugin just takes the latest created field value from the database (ordered by meta_id) and uses its type in the snippet, so we have this in the snippet:

register_meta( 'post', 'youtube_link', array( 'type' => 'object', 'single' => true, 'show_in_rest' => array( 'schema' => array( 'type' => 'object', 'additionalProperties' => true ) ) ) ); 

But it should be like this:

register_meta( 'post', 'youtube_link', array( 'type' => 'string', 'single' => true, 'show_in_rest' => true ) ); 

What to do?

The most proper way is to clean up your database from “incorrect” old entries and then go to plugin settings and copy the updated version of the snippet to the subsites one more time.

There is also an easy way though – just rename your custom field and then update the snippet.

Need more help?