You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugins/hwp-previews/index.md
+143-1Lines changed: 143 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,4 +3,146 @@ title: "HWP Previews"
3
3
description: "HWP Previews plugin enables seamless preview functionality for headless WordPress applications, allowing content creators to preview their changes in the frontend application before publishing."
4
4
---
5
5
6
-
@TODO
6
+
## Introduction
7
+
8
+
**HWP Previews** is a headless preview solution for WordPress that provides fully configurable preview URLs via a settings interface.
9
+
10
+
This plugin bridges the preview gap in headless WordPress architectures, allowing content creators to preview their changes in the front-end application before publishing.
11
+
12
+
## Table of Contents
13
+
14
+
*[Key Features](#key-features)
15
+
*[Setup](#setup)
16
+
*[Project Structure](#project-structure)
17
+
*[Configuration](#configuration)
18
+
*[Front-End Integration](#front-end-integration)
19
+
*[Using With Faust.js](#using-with-faustjs)
20
+
*[Documentation](#documentation)
21
+
*[Contributing](#contributing)
22
+
23
+
## Key Features
24
+
25
+
### Framework Agnostic
26
+
27
+
The plugin works with any front-end framework (Next.js, Nuxt, React, Vue, etc.) and data-fetching method (WPGraphQL, REST API, or custom endpoints).
28
+
29
+
### Per Post Type Configuration
30
+
31
+
Configure preview behavior independently for each public post type:
32
+
33
+
* Enable or disable previews
34
+
* Define custom URL templates with dynamic parameters
35
+
* Choose between iframe or new tab preview modes
36
+
* Allow draft posts as parents for hierarchical types
37
+
38
+
### Dynamic URL Templates
39
+
40
+
Use placeholder tokens to build context-rich preview URLs:
41
+
42
+
*`{ID}` - Post ID
43
+
*`{author_ID}` - Post author's user ID
44
+
*`{status}` - Post status (draft, pending, etc.)
45
+
*`{slug}` - Post slug
46
+
*`{parent_ID}` - Parent post ID (for hierarchical types)
47
+
*`{type}` - Post type slug
48
+
*`{template}` - Template filename
49
+
50
+
### Extensible Architecture
51
+
52
+
Extend the plugin through WordPress hooks and filters to add custom parameters, modify settings, or integrate with other plugins.
53
+
54
+
### Faust.js Integration
55
+
56
+
Automatic integration with Faust.js that pre-configures preview URLs and removes conflicts while maintaining existing workflows.
57
+
58
+
***
59
+
60
+
## Setup
61
+
62
+
Once the plugin is installed and activated, you can configure it under Settings > HWP Previews.
63
+
64
+
By default, no post types are configured unless you have Faust.js installed, which triggers automatic configuration.
65
+
66
+
### Quick Start
67
+
68
+
| Step | Action | Description |
69
+
| ---- | ------ | ----------- |
70
+
| 1 | Navigate to Settings | Go to **Settings > HWP Previews** in WordPress admin |
71
+
| 2 | Choose a post type | Click the tab for the post type (Posts, Pages, etc.) |
│ ├── Preview/ # Preview URL resolver, parameters, and services
100
+
│ ├── Plugin.php # Main plugin class (entry point)
101
+
│ └── Autoloader.php # PSR-4 autoloader
102
+
├── examples/ # Example front-end integrations
103
+
│ ├── hwp-preview-wpgraphql/ # Next.js + WPGraphQL example
104
+
│ └── hwp-preview-rest/ # Next.js + REST API example
105
+
├── tests/ # Test suites
106
+
│ ├── wpunit/ # WPBrowser/Codeception unit tests
107
+
└─ └── e2e/ # End-to-end tests
108
+
```
109
+
110
+
***
111
+
112
+
## Front-End Integration
113
+
114
+
HWP Previews is framework and API agnostic. You can integrate it with any front-end application and data-fetching method (WPGraphQL, REST API, or custom endpoints).
115
+
116
+
### Example Implementations
117
+
118
+
We provide working examples in the `examples/` directory:
119
+
120
+
***[hwp-preview-wpgraphql](https://github.com/wpengine/hwptoolkit/tree/main/plugins/hwp-previews/examples/hwp-preview-wpgraphql)**: Next.js with WPGraphQL using Draft Mode
121
+
***[hwp-preview-rest](https://github.com/wpengine/hwptoolkit/tree/main/plugins/hwp-previews/examples/hwp-preview-rest)**: Next.js App Router with REST API
122
+
123
+
### Framework-Specific Preview Guides
124
+
125
+
To implement previews from scratch, refer to your framework's documentation:
HWP Previews automatically integrates with [Faust.js](https://faustjs.org/) when both plugins are active. See the [Integrate with Faust.js](how-to/integrate-with-faust/index.md) guide for details.
If you feel like something is missing or you want to add documentation, we encourage you to contribute! Please check out our [Contributing Guide](https://github.com/wpengine/hwptoolkit/blob/main/CONTRIBUTING.md) for more details.
0 commit comments