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

Open
adamziel opened this issue May 26, 2025 · 0 comments
Open

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

adamziel opened this issue May 26, 2025 · 0 comments

Comments

@adamziel
Copy link
Contributor

adamziel commented May 26, 2025

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 );
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant