• Resolved mickhele

    (@mickhele)


    How can I apply automatically the same “search exclude” settings to the others pages translated?
    Now I’ve to open every page translated and set manually the “search exclude”.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor pronskiy

    (@pronskiy)

    Hi!

    It is possible but may require a bit of coding.

    Off the top of my head, adding the following code to your functions.php should help:

    
    function update_wpml_translations($post_id)
    {
    	if (!isset($_POST['sep'])) return $postId;
    
    	$sep = $_POST['sep'];
    	$exclude = (isset($sep['exclude'])) ? filter_var($sep['exclude'], FILTER_VALIDATE_BOOLEAN) : false;
    
    	$post_ids = [$post_id];
    	$languages = apply_filters( 'wpml_active_languages', null );
    	foreach ($languages as $language) {
    		$post_ids[] = apply_filters( 'wpml_object_id', $post_id, 'page', true, $language );
    	}
    
    	do_action('searchexclude_hide_from_search', $post_ids, $exclude);
    }
    add_filter('post_updated', 'update_wpml_translations', 10, 2);
    

    ?? Not tested ??

    Thread Starter mickhele

    (@mickhele)

    Ok, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WPML compatibility’ is closed to new replies.