WP_CLI\Fetchers

Post{}WP-CLI 1.0

Fetch a WordPress post based on one of its attributes.

Хуков нет.

Использование

$Post = new Post();
// use class methods

Методы

  1. public get( $arg )

Код Post{} WP-CLI 2.8.0-alpha

class Post extends Base {

	/**
	 * The message to display when an item is not found.
	 *
	 * @var string
	 */
	protected $msg = 'Could not find the post with ID %d.';

	/**
	 * Get a post object by ID
	 *
	 * @param string $arg The raw CLI argument.
	 * @return WP_Post|array|false The item if found; false otherwise.
	 */
	public function get( $arg ) {
		$post = get_post( $arg );

		if ( null === $post ) {
			return false;
		}

		return $post;
	}
}