This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Use a supplemental SearchWP Engine for BetterDocs searches. | |
add_filter( 'searchwp_betterdocs_engine', function( $engine, $params ) { | |
return 'my_engine_name'; | |
}, 20, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Template Name: SearchWP Term Archive Priority Sample */ | |
global $post; | |
// Retrieve applicable query parameters. | |
$search_query = isset( $_GET['searchwp'] ) ? sanitize_text_field( $_GET['searchwp'] ) : null; | |
$search_page = isset( $_GET['swppg'] ) ? absint( $_GET['swppg'] ) : 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Tell SearchWP to drop Media with no parent when Parent Attribution has been enabled. | |
// This was the default behavior in SearchWP 3 but has changed in SearchWP 4. | |
add_filter( 'searchwp\source\post\attachment\parent_attribution\strict', '__return_true' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'searchwp\source\post\drop', function( $args ) { | |
do_action( 'searchwp\debug\log', "Drop event for post {$args['post_id']}", 'backtrace' ); | |
$e = new \Exception(); | |
$trace = explode( "\n", $e->getTraceAsString() ); | |
$trace = array_reverse( $trace ); | |
array_shift( $trace ); | |
array_pop( $trace ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'searchwp\source\gravity_forms\entry\raw', '__return_true' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$searchwp = new \SearchWP\Query( 'marketing', [ | |
'engine' => 'gravity', | |
'fields' => 'all', | |
] ); | |
foreach ( $searchwp->results as $result ) { | |
switch ( get_class( $result ) ) { | |
case 'SearchWP\Sources\GravityForms\Entry': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! have_posts() ) : ?> | |
<p>No results</p> | |
<?php endif; return; ?> | |
<?php | |
$grouped_results = []; | |
$no_term_results = []; | |
while ( have_posts() ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Search results are contained within a div.searchwp-live-search-results | |
* which you can style accordingly as you would any other element on your site | |
* | |
* Some base styles are output in wp_footer that do nothing but position the | |
* results container and apply a default transition, you can disable that by | |
* adding the following to your theme's functions.php: | |
* | |
* add_filter( 'searchwp_live_search_base_styles', '__return_false' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Disable SearchWP's automatic integration with WP All Import. | |
add_filter( 'searchwp\integration\wp-all-import', '__return_false' ); | |
add_action( 'pmxi_before_xml_import', function( $import_id ) { | |
\SearchWP::$indexer->pause(); | |
}, 10 ); | |
add_action( 'pmxi_saved_post', function( $post_id ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This is an (arguably messy) setup to test what might be a hook issue. | |
* | |
* Jchristopher_Hook_ID_Test_Alpha stores an array of strings to prepend to the_content. | |
* It has a hook jchristopher_test allowing for other code to modify the array of strings. | |
* It has its own string 'alpha'. | |
* | |
* Jchristopher_Hook_ID_Test_Beta has its own string 'beta' and uses the hook from the |