Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: has_archive to post types rest endpoint. #3294

Conversation

jorgefilipecosta
Copy link
Member

Backports WordPress/gutenberg#42746 to the core. It adds an has_archive field to the post types endpoint.

Testing

Added the following snippet:

add_action( 'init', function() {
	register_post_type(
		'book',
		array(
			'label'                 => __( 'Book' ),
			'description'           => __( 'Books' ),
			'supports'              => array( 'title', 'editor' ),
			'taxonomies'            => array( 'category', 'post_tag' ),
			'hierarchical'          => false,
			'public'                => true,
			'show_ui'               => true,
			'show_in_menu'          => true,
			'show_in_admin_bar'     => true,
			'show_in_nav_menus'     => true,
			'show_in_rest'          => true,
			'can_export'            => true,
			'has_archive'           => true,
			'exclude_from_search'   => false,
			'publicly_queryable'    => true,
		)
	);
	flush_rewrite_rules();
} );

Pasted wp.apiFetch( { path: '/wp/v2/types' } ).then( console.log ); on the browser console and verified book post type contained has_archive true.

@jorgefilipecosta jorgefilipecosta force-pushed the add/has-archive-to-post-types-endpoitn branch 5 times, most recently from ec54d62 to 2938017 Compare September 21, 2022 11:15
@jorgefilipecosta jorgefilipecosta force-pushed the add/has-archive-to-post-types-endpoitn branch from 2938017 to 7c6935c Compare September 21, 2022 11:30
@jorgefilipecosta
Copy link
Member Author

Committed in 34ace23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant