
Polylang has two options for syncing custom fields – all or nothing, but in some cases we need more fine-grain control.
The usual requirement is to be able to exclude one or two fields, while syncing the majority – the alternative is to not sync any of the post meta and instead require content editors to manually enter all data in each translated post copy – this is both tedious and prone to error.
Here is a simple filter function to allow for specified post meta fields to be excluded from this sync.
We find a number of users who request this functionality and are considering adding this to the main PolyLang settings page in the future.
shorter version:
add_filter( ‘pll_copy_post_metas’, function($metas) {
$unsync = array (
‘team_player’
);
return array_diff($metas, array_keys($unsync));
});