$this->postType, 'numberposts' => $this->maxOptionsNumber, 'fields' => [ 'ids', 'post_title'] ]); return array_map( function( $post ){ return [ 'label' => $post->post_title, 'value' => $post->ID ]; }, $posts ); } /** * @inheritdoc */ public function check( $value = null ){ global $post; $value = $value ?? $this->value; // if it was not a singular WP page if ( is_null( $post ) || ! is_singular() ) { $isMet = false; } else { $isMet = ! empty( $value ) ? in_array( $post->ID, $value ) : is_singular( $this->postType ); } return $this->selectionMode === 'include' ? $isMet : !$isMet; } }