WP_REST_Controller::update_item() WordPress Method

The WP_REST_Controller::update_item() method is used to update a single item in a WordPress database. This method accepts two arguments: the first is the ID of the item to be updated, and the second is an array of data to be updated. This method can be used to update any type of data in a WordPress database, including posts, pages, comments, and custom post types.

WP_REST_Controller::update_item( WP_REST_Request $request ) #

Updates one item from the collection.


Parameters

$request

(WP_REST_Request)(Required)Full details about the request.


Top ↑

Return

(WP_REST_Response|WP_Error) Response object on success, or WP_Error object on failure.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-controller.php

	public function update_item( $request ) {
		return new WP_Error(
			'invalid-method',
			/* translators: %s: Method name. */
			sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ),
			array( 'status' => 405 )
		);
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.