Skip to content

Instantly share code, notes, and snippets.

Jon Christopher jchristopher

View GitHub Profile
@jchristopher
jchristopher / functions.php
Created Apr 22, 2019
Customize AND fields per post type in SearchWP
View functions.php
<?php
add_filter( 'searchwp_and_fields_post', function( $and_fields, $engine ) {
// TODO: Customize $and_fields to match what you want for Posts (and not other post types).
// @link https://searchwp.com/docs/hooks/searchwp_and_fields/
return $and_fields;
}, 20, 2 );
@jchristopher
jchristopher / functions.php
Created Apr 22, 2019
Tell SearchWP to more aggressively apply delta updates to the index
View functions.php
<?php
// Tell SearchWP to more aggressively apply delta updates to the index.
add_filter( 'searchwp_aggressive_delta_update', '__return_true' );
@jchristopher
jchristopher / functions.php
Created Apr 22, 2019
Control whether individual ACF sub-fields are omitted from SearchWP's Custom Fields dropdown
View functions.php
<?php
add_filter( 'searchwp_acf_remove_repeatable_child', function( $remove, $context ) {
// TODO: Determine whether this field should be removed.
reeturn $remove; // true/false
}, 20, 2 );
@jchristopher
jchristopher / functions.php
Created Apr 22, 2019
Prevent SearchWP from removing ACF repeatables sub-fields from the Custom Fields dropdown
View functions.php
<?php
add_filter( 'searchwp_acf_remove_repeatable_children', function( $remove, $context ) {
// TODO: Determine whether ACF sub-fields should be removed from the Custom Fields dropdown.
return $remove; // true/false
}, 20, 2 );
@jchristopher
jchristopher / functions.php
Created Apr 22, 2019
Tell SearchWP to remove Advanced Custom Fields (ACF) field references when indexing
View functions.php
<?php
// NOTE: See https://searchwp.com/docs/hooks/searchwp_acf_remove_field_references/
add_filter( 'searchwp_acf_remove_field_references', function( $remove, $context ) {
// TODO: Determine whether ACF field references should be removed.
return $remove; // true/false
}, 20, 2 );
@jchristopher
jchristopher / functions.php
Created Apr 22, 2019
Customize whether individual ACF field references are removed in SearchWP
View functions.php
<?php
add_filter( 'searchwp_acf_remove_field_reference', function( $remove, $context ) {
// TODO: Determine whether this field should be removed.
return $remove; // true/false
}, 20, 2 );
@jchristopher
jchristopher / functions.php
Created Apr 22, 2019
Filter arguments sent to SWP_Query before a search is run in SearchWP
View functions.php
<?php
add_filter( 'searchwp_swp_query_args', function( $args ) {
// TODO: Modify $args as you see fit.
return $args;
} );
@jchristopher
jchristopher / functions.php
Last active Apr 22, 2019
Modify post(s) before SearchWP indexes them
View functions.php
<?php
// Modify post(s) before SearchWP indexes them.
add_filter( 'searchwp_pre_set_post', function( $the_post ) {
// TODO: Modify $the_post in any way you see fit.
return $the_post;
} );
@jchristopher
jchristopher / functions.php
Created Apr 22, 2019
Modify PDF metadata before it gets indexed in SearchWP
View functions.php
<?php
// Modify PDF metadata before it gets indexed in SearchWP.
add_filter( 'searchwp_pdf_metadata', function( $pdf_metadata, $post_id ) {
// TODO: Modify $pdf_metadata as you see fit.
return $pdf_metadata;
}, 20, 2 );
@jchristopher
jchristopher / functions.php
Created Apr 22, 2019
Modify taxonomy terms for posts during SearchWP indexing.
View functions.php
<?php
// Modify taxonomy terms for posts during SearchWP indexing.
add_filter( 'searchwp_indexer_taxonomy_terms', function( $terms, $taxonomy, $post_being_indexed ) {
// TODO: modify $terms in any way you'd like.
return $terms;
}, 20, 3 );
You can’t perform that action at this time.