Note: You are viewing the documentation for Version 4View Version 3 Docs

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

Fix keyword search on your site. No coding required!

Now you can utilize all of the content that's gone unrecognized by native WordPress keyword search instantly with SearchWP

Get SearchWP