Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.
This repository was archived by the owner on May 30, 2025. It is now read-only.

[Blueprints v2] Create custom post types using SCF #21

Open
@adamziel

Description

@adamziel
Contributor

This code could replace adding a custom mu-plugin when handling postTypes:

	$instance = acf_get_internal_post_type_instance( 'acf-post-type' );
	if ( ! $instance ) {
		return;
	}

	// Define our post type configuration (similar to what you'd fill in the UI)
	// This structure mirrors what SCF creates when you use the UI to create a post type
	$post_type_config = array(
		'key'                => 'scf_test_post_type',
		'title'              => 'SCF Test Type',
		'post_type'          => 'scf-test-type',
		'description'        => 'Test post type for testing',
		'active'             => 1,
		'public'             => 1,
		'show_in_rest'       => 1,
		'publicly_queryable' => 1,
		'show_ui'            => 1,
		'show_in_menu'       => 1,
		'has_archive'        => 1,
		'supports'           => array( 'title', 'editor' ),
		'labels'             => array(
			'name'          => 'SCF Test Type',
			'singular_name' => 'SCF Test Item',
		),
	);

	// Create the post type entry in the database using SCF's internal API
	$result = $instance->update_post( $post_type_config );

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @adamziel

        Issue actions

          [Blueprints v2] Create custom post types using SCF · Issue #21 · Automattic/php-toolkit