[ 'type' => 'number', ], 'postType' => [ 'type' => 'string', 'default' => 'post', ], 'className' => [ 'type' => 'string', ], 'align' => [ 'type' => 'string', ], ]; /** * Render callback * * @param array $attributes block attributes. * * @return false|string */ public function render( $attributes ) { if ( empty( $attributes['postId'] ) ) { return ''; } $query = new \WP_Query( [ 'p' => $attributes['postId'], 'post_type' => 'any', ] ); set_query_var( 'query', $query ); $output = $this->get_content_from_template( $attributes ); if ( $output ) { return $output; } ob_start(); load_template( dirname( __FILE__ ) . '/template.php', false ); $output = ob_get_contents(); ob_end_clean(); return $output; } }