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.
1
<?php
2
3
add_filter('weglot_is_eligible_url', 'not_authorize_translation');
4
function not_authorize_translation(){
5
if (get_post_type( weglot_get_postid_from_url() ) === 'book') {
6
return false;
7
}
8
9
return true;
10
}
11
12
add_filter('weglot_active_translation_before_process', 'check_page_translation');
13
function check_page_translation()
14
{
15
if (get_post_type(weglot_get_postid_from_url()) === 'book' && weglot_get_current_language() !== weglot_get_original_language() ) {
16
wp_redirect( weglot_get_request_url_service()->get_full_url_no_language() );
17
exit;
18
}
19
20
return true;
21
}
Copied!
Last modified 2yr ago
Copy link