Exclude a Custom Post Type

To avoid adding URLs to the Weglot exclusion list, you can disable the translation of a Custom Post Type (example: "book") directly with our hooks.

<?php
add_filter('weglot_is_eligible_url', 'not_authorize_translation');
function not_authorize_translation(){
if (get_post_type( weglot_get_postid_from_url() ) === 'book') {
return false;
}
return true;
}
add_filter('weglot_active_translation_before_process', 'check_page_translation');
function check_page_translation()
{
if (get_post_type(weglot_get_postid_from_url()) === 'book' && weglot_get_current_language() !== weglot_get_original_language() ) {
wp_redirect( weglot_get_request_url_service()->get_full_url_no_language() );
exit;
}
return true;
}