Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created June 15, 2020 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/a1136cd5e05268c4a706b8498813b6e8 to your computer and use it in GitHub Desktop.
Save jchristopher/a1136cd5e05268c4a706b8498813b6e8 to your computer and use it in GitHub Desktop.
Add private Custom Post Types to SearchWP.
<?php
// Add private Custom Post Types to SearchWP.
add_filter( 'searchwp\sources', function( $sources ) {
// Create a Source from each private CPT e.g.
$sources[] = new \SearchWP\Sources\Post( 'my_private_cpt_name_1' );
$sources[] = new \SearchWP\Sources\Post( 'my_private_cpt_name_2' );
$sources[] = new \SearchWP\Sources\Post( 'my_private_cpt_name_3' );
return $sources;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment