This file contains 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 | |
function searchwp_custom_timeout() | |
{ | |
return 25; | |
} | |
add_filter( 'swp_timeout', 'searchwp_custom_timeout' ); |
This file contains 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: Genesis and SearchWP integration with pagination */ | |
function prefix_searchwp_form( $query ) { | |
echo '<form class="searchwp-form" action="" method="get">'; | |
echo '<input type="text" id="searchwpquery" name="searchwpquery" value="' . esc_attr( $query ) . '" />'; | |
echo '<button type="submit">' . __( 'Search', 'text-domain' ) . '</button>'; | |
echo '</form>'; | |
} |
This file contains 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 | |
function mySearchIncludeIds( $ids, $engine, $terms ) | |
{ | |
$ids = get_page_ids_user_can_access(); // returns array of post IDs that the user has access to | |
return $ids; | |
} | |
add_filter( 'searchwp_include', 'my_limit_search_results', 10, 3 ); |
This file contains 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 | |
/** | |
* The template for displaying Search Results pages. | |
* | |
* @package WordPress | |
* @subpackage Twenty_Thirteen | |
* @since Twenty Thirteen 1.0 | |
*/ | |
get_header(); ?> |
This file contains 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 | |
function myChangeDigitThreshold() | |
{ | |
return 15; // 15% maximum threshold | |
} | |
add_filter( 'searchwp_fuzzy_digit_threshold', 'myChangeDigitThreshold' ); |
This file contains 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 | |
function searchwp_include_only_category( $ids, $engine, $terms ) { | |
// Limit to category 10 | |
$categoryID = 10; | |
// Retrieve the IDs of all the posts in this category | |
$args = array( | |
'category' => $categoryID, | |
'fields' => 'ids', |
This file contains 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 | |
function my_searchwp_stopwords( $terms ) { | |
// add 'lorem', 'ipsum', and 'dolor' to SearchWP's default terms | |
$terms[] = 'lorem'; | |
$terms[] = 'ipsum'; | |
$terms[] = 'dolor'; | |
return $terms; | |
} |
This file contains 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 | |
function myPhraseSynonyms( $terms ){ | |
// if the person searched for 'super hero' let's add 'superhero' | |
if( in_array( 'super', $terms ) && in_array( 'hero', $terms ) ) { | |
// remove 'super' and 'hero' | |
foreach( $terms as $key => $term ) { | |
if( $term == 'super' || $term == 'hero' ) { |
This file contains 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 | |
function mySwpCustomFields( $keys ) { | |
// $keys is an array of Custom Field keys | |
// I want to add 'sku' to that list | |
$keys[] = 'sku'; | |
// I need to return my customized array back to SearchWP | |
return $keys; | |
} |
This file contains 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 | |
function change_logged_in_duration( $expirein ) { | |
if( !current_user_can( 'edit_posts' ) ) { | |
return 31556926; // 1 year in seconds | |
} | |
} | |
add_filter( 'auth_cookie_expiration', 'change_logged_in_duration' ); |