---
url: /cookbook/enable-editor.md
description: >-
  Enable WPCE for selected post types or individual templates using the
  wpce_enable_for_post_types and wpce_enable_for_post filters.
---

# Enable the Editor

By default, the WPCE is not used anywhere. You have to enable it through code.

## Enable For Specific Post Types

If you want to enable the editor for any post type, you can use the [`wpce_enable_for_post_types` filter](../hooks/filters/wpce-enable-for-post-types).

## Enable for Specific Templates

Sometimes it is useful to only show the WPCE editor when a specific template (usually a page template) is selected.
This tends to be the case when trying to integrate the WPCE into an extisting website without having to rebuild
all of the content at once.

```php
add_filter('wpce_enable_for_post', function (bool $enabled, WP_Post $post) {
	// Bail if this post already has a disabled WPCE editor or is not a page
	if (!$enabled || $post->post_type !== 'page') return $enabled;

	// Show editor in these templates
	$allowed_page_templates = ['contact.php'];

	$template = get_page_template_slug($post);

	return in_array($template, $allowed_page_templates);
}, 10, 2);
```
