Skip to content

Pattern Directory Items

Arun Prakash edited this page Sep 21, 2025 · 1 revision

Pattern Directory Items

The WordPress Pattern Directory endpoint lists reusable block patterns from the directory.

  • Endpoint: GET /wp/v2/pattern-directory/patterns
  • Typical query params: search, page, per_page, category (ID), keyword (ID), slug, offset, order, orderby (supports favorite_count)

Fluent usage (recommended)

final res = await client.patternDirectory.query
  .withSearch('hero')
  .withOrder(Order.desc)
  // "favorite_count" is supported by the Pattern Directory endpoint
  .withOrderBy('favorite_count')
  .withPerPage(10)
  .execute();

res.map(
  onSuccess: (s) {
    for (final p in s.data) {
      // p is PatternDirectoryItem
      print('${p.id}: ${p.title}');
    }
    return null;
  },
  onFailure: (f) {
    print('Failed: ${f.message ?? ''}');
    return null;
  },
);

Typed request (optional)

final res = await client.patternDirectory.list(
  ListPatternDirectoryItemsRequest(
    search: 'hero',
    perPage: 5,
    order: Order.desc,
    orderBy: OrderBy.favorite_count,
  ),
);

Response model

PatternDirectoryItem fields include:

  • id (int)
  • title (String)
  • content (String)
  • description (String?)
  • categories (List?)
  • keywords (List?)
  • viewportWidth (int?)
  • blockTypes (List?)

Note: This endpoint usually does not require authentication. Behaviors may vary by site configuration.

Clone this wiki locally