Skip to content
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

@adamziel

Description

@adamziel

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 );

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

    Issue actions