Skip to content

global $post is not set in REST API context #1

@joemaller

Description

@joemaller

This is blowing up the editor:

global $post;
$args = is_array($rawArgs) ? $rawArgs : $this->defaults;
$cleanArgs = [];
/**
* Ensure a $post is set and is a valid WP_POST object
*/
$cleanArgs['post'] = array_key_exists('post', $args) ? $args['post'] : $post;
$cleanArgs['post'] = get_post($cleanArgs['post']); // returns a WP_Post or null

Two things need to happen:

  • 1. The editor block needs to send the post ID along with weights and post_types
  • 2. The library needs to fall back to the most recently published post if nothing is provided.

Metadata

Metadata

Assignees

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