For the complete documentation index, see llms.txt. This page is also available as Markdown.

Exclude a Custom Post Type

To avoid adding URLs to the Weglot exclusion list, you can disable the translation of a given post type directly with our hooks. In the example below we exclude the built-in page type — replace 'page' with your own Custom Post Type slug.

<?php

add_filter( 'weglot_is_eligible_url', 'not_authorize_translation' );
function not_authorize_translation( $eligible ) {
	if ( get_post_type( weglot_get_postid_from_url() ) === 'page' ) {
		return false;
	}
	return $eligible;
}

add_filter( 'weglot_active_translation_before_process', 'check_page_translation' );
function check_page_translation() {
	if ( get_post_type( weglot_get_postid_from_url() ) === 'page' && weglot_get_current_language() !== weglot_get_original_language() ) {
		wp_redirect( weglot_get_request_url_service()->get_full_url() );
		exit;
	}

	return true;
}

Last updated