Skip to main content

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.

SettingDescription
Post TypesOpt-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.
UnitsChoose whether generated introductions should be limited by words or paragraphs. Default: paragraphs.
LimitNumber of words or paragraphs to include. Default: 1.
Minimum Words Per ParagraphOnly 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

  1. Enable automatic generation for one or more post types in the settings screen.
  2. Leave the Custom Introduction field empty when you want Yoko Core to populate it automatically.
  3. Add a More tag in the post content when you need a hand-authored preview cutoff.
  4. 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 yoko namespace.
  • If --unit and --limit are omitted, the command uses the saved Content Gating settings.
  • Use --force to regenerate posts that already have a saved Custom Introduction.
  • Without --force, posts with existing custom_excerpt meta 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.