Inicio - Documentación - POM Theme - 11 Developers - 11.5 Content models - Register structured content programmatically

Register structured content programmatically

Choose one owner for a post type, taxonomy or field schema.

Editor-owned model

Create it under Settings → POM Theme → Content model when the site owner should manage the model through POM. POM then exposes it to the editor, templates, builder selectors and related systems.

Plugin-owned model

Use WordPress's public APIs when the integration owns the schema:

add_action(
    'init',
    static function (): void {
        register_post_type(
            'resource',
            array(
                'label'        => __( 'Resources', 'my-plugin' ),
                'public'       => true,
                'show_in_rest' => true,
                'supports'     => array( 'title', 'editor', 'thumbnail' ),
            )
        );
    }
);

Register taxonomies with register_taxonomy() and metadata with register_post_meta() including an appropriate REST schema/auth callback when exposed.

POM Theme discovers supported public WordPress content types for selectors. A plugin should not duplicate its model into POM's saved settings or write framework repeater data.

Join the POM content-model catalog

Register the post type with WordPress first. If it must also participate in the POM-only catalog used by template and content-model settings, append its normalized definition with pom_theme_formatted_custom_post_types:

add_filter(
    'pom_theme_formatted_custom_post_types',
    static function (array $post_types): array {
        $post_types['resource'] = array(
            'registration_owner' => 'plugin',
            'slug'               => 'resource',
            'singular'           => __('Resource', 'my-plugin'),
            'plural'             => __('Resources', 'my-plugin'),
            'publicly_queryable' => 'yes',
            'has_archive'        => 'yes',
            'enable_content'     => 'yes',
            'enable_thumbnail'   => 'yes',
            'single_layout'      => 'simple',
        );

        return $post_types;
    }
);

The filter does not call register_post_type() and does not grant capabilities. Set registration_owner to plugin so POM Theme does not register the same slug from a stale saved row or alter the post type through its permalink settings. The plugin remains the only owner of registration, rewrite rules, REST exposure, permissions, storage, migration, and deletion. Use a stable array key and slug, return the complete array, and do not modify POM Framework's saved repeater.

Compatibility checklist

  • Stable unique slugs/keys; never reuse a core/reserved identifier.
  • Rewrite/public query behavior decided before production content.
  • Explicit capabilities and map_meta_cap decisions.
  • REST exposure only for fields that should be public/editable.
  • Sanitization and authorization callbacks for metadata.
  • Archive/single template strategy and empty values.
  • Faceted-search indexing only for short structured values.
  • Migration and deactivation behavior that does not delete user content unexpectedly.