Content Gating/Protection
Yoko Core comes with a built in content gating feature that meets the needs of most Yoko Co clients.
Main Options
The main Content Gating settings live on the existing Yoko SSO and Content Protection settings screen.
Automatic Custom Introduction Generation
The Custom Introduction field in the Content Protection metabox can now be generated automatically for selected post types.
| Setting | Description |
|---|---|
| Post Types | Opt-in list of public post types that should auto-generate the Custom Introduction field. This field uses Select2 for easier searching on sites with many post types. Nothing is enabled by default. |
| Units | Choose whether generated introductions should be limited by words or paragraphs. Default: paragraphs. |
| Limit | Number of words or paragraphs to include. Default: 1. |
| Minimum Words Per Paragraph | Only used when the unit is paragraphs. If the first paragraph is shorter than this threshold and another paragraph exists, the generator includes the second paragraph too. Default: 20. |
Generation Rules
- Automatic generation only runs for the post types selected in settings.
- Automatic generation only fills the Custom Introduction field when it is empty.
- If an editor writes a Custom Introduction manually, future saves leave that value alone.
- If the post content contains a WordPress More tag, everything before the More tag takes precedence over the global word or paragraph settings.
- When paragraph mode is enabled and the limit is
1, a short lead paragraph can expand the generated preview to two paragraphs so the teaser still reads naturally.
Content Gating Metabox
When a post type has automatic Custom Introduction generation enabled, the Content Protection metabox shows an informational notice so editors know the field can be generated from the main content.
The metabox also includes a note explaining that the WordPress More tag overrides the automatic settings. This gives editors a lightweight per-post way to choose the exact preview break without changing global configuration.
Editorial Workflow
- Enable automatic generation for one or more post types in the settings screen.
- Leave the Custom Introduction field empty when you want Yoko Core to populate it automatically.
- Add a More tag in the post content when you need a hand-authored preview cutoff.
- Enter a Custom Introduction manually when a post needs a fully custom gated preview.
WP-CLI Regeneration
Use WP-CLI to preview or regenerate introductions in bulk:
wp yoko custom_excerpt --post_type=resource --dry-run
wp yoko custom_excerpt --post_type=resource --force
wp yoko custom_excerpt --post_type=resource --unit=paragraphs --limit=2
Behavior notes:
- The command lives under the root
wp yokonamespace. - If
--unitand--limitare omitted, the command uses the saved Content Gating settings. - Use
--forceto regenerate posts that already have a saved Custom Introduction. - Without
--force, posts with existingcustom_excerptmeta are skipped.
PDF Gating
The build-in content gating feature supports gating PDF files when used in conjunction with the in-page PDF viewer. When the viewer is activated for all PDFs or a single PDF, the standard content protection metabox is revealed.
PDF Gating in Full Site Editing Block Themes
When using a FSE block theme, the PDF Viewer options allow you to select the template that should be rendered if the current user shouldn't have access to the PDF.