> 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/wordpress/use-cases/exclude-the-search-page-from-translations-1.md).

# Exclude draft or private status post

If you would like to exclude a page that is in draft or private status, you can add the code below:

```php
<?php

add_action( 'pre_get_posts', 'custom_weglot_exclude_draft_private_redirect' );
function custom_weglot_exclude_draft_private_redirect() {
	global $post;
	if ( $post ) {
		$post_status = get_post_status( $post->ID );
		if ( ! function_exists( 'weglot_get_original_language' ) || ! function_exists( 'weglot_get_current_language' ) ) {
			return;
		}
		if ( ( $post_status == 'draft' || $post_status == 'private' ) && ! is_admin() && weglot_get_original_language() != weglot_get_current_language() ) {
			wp_redirect( weglot_get_full_url_no_language(), 301 );
			exit;
		}
	}
}

add_filter( 'weglot_button_html', 'custom_weglot_exclude_draft_private_no_selector' );
function custom_weglot_exclude_draft_private_no_selector( $button_html ) {
	global $post;
	if ( $post ) {
		$post_status = get_post_status( $post->ID );
		if ( ( $post_status == 'draft' || $post_status == 'private' ) && ! is_admin() ) {
			return '';
		}
	}
	return $button_html;
}
```
