> For the complete documentation index, see [llms.txt](https://developers.weglot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.weglot.com/cms/wordpress/use-cases/exclude-a-custom-post-type.md).

# 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.

The two filters do different jobs, and you need both:

* `weglot_is_eligible_url` marks the URL as not translatable for the language switcher and the `hreflang` tags. On its own, it does **not** stop the page from being translated.
* `weglot_active_translation_before_process` is what keeps the page in its original language: a visitor who reaches a translated URL of such a page is redirected to the original one.

```php
<?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;
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.weglot.com/cms/wordpress/use-cases/exclude-a-custom-post-type.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
