SearchWP

searchwp\post_stati

Since: 4.0.0

Table of Contents

Control the considered post stati for \WP_Post-based Sources.

Parameters

Type Parameter Default Since
String[] $post_stati Post stati that are public and not excluded from search 4.0.0
Array $args
Key Type Value
engine String Engine name
4.0.0

Examples

All hooks should be added to your custom SearchWP Customizations Plugin.

Include drafts in Supplemental Engine

<?php
// Include drafts in SearchWP Supplemental Engine.
add_filter(
'searchwp\post_stati',
function( $post_stati, $args ) {
if ( 'supplemental_engine' === $args['engine'] ) {
$post_stati[] = 'draft';
}
return $post_stati;
},
20, 2
);

How to use this code