• Resolved Methodos

    (@methodos)


    Hi,
    I added some custom fields to the Pages admin. Every time I update a page in one language, the option is also changed for another page in another language which has nothing to do with this option I want to set. How to disable the saving of custom field in other posts then the one I am editing?

    https://www.ads-software.com/plugins/polylang/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Chrystl

    (@chrystl)

    Hi
    Did you disable the “Custom fields” synchronization in Settings > Languages > Settings > Synchronization?

    Thread Starter Methodos

    (@methodos)

    I don’t want to disable that. I only need to disable it for one or two fields.
    So, I have this:

    function save_meta_box($post_id) {
    	if($post_id == THEMAINPOSTID)
    	{
    		update_post_meta("","");
    	}
    }
    add_action ( 'save_post', 'save_meta_box' );

    And I need to have THEMAINPOSTID substituted by a real function/variable.

    Thread Starter Methodos

    (@methodos)

    Adding this to functions.php did the trick:

    function unset_important_metadata($metakeys)
    {
    	$unique_language_keys = array("certain_inputvalue", "another_inputvalue");
    	foreach($metakeys as $key => $value)
    	{
    		if(in_array($value, $unique_language_keys, true))
    		{
    			unset($metakeys[$key]);
    		}
    	}
    	return $metakeys;
    }
    add_filter('pll_copy_post_metas', 'unset_important_metadata',1,1);
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘custom fields overwritten’ is closed to new replies.