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_excluded_custom_fields( $excluded ) { | |
// out of the box SearchWP ignores it's own meta fields so it's important to not overwrite $excluded | |
// ignore my_custom_field | |
$excluded[] = 'my_custom_field'; | |
return $excluded; | |
} |
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_omit_meta_key( $omit, $custom_field, $post ) { | |
// ignore my_custom_field | |
if ( 'my_custom_field' === $custom_field ) { | |
$omit = true; | |
} | |
return $omit; |
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 | |
// ignore my_custom_field | |
add_filter( 'searchwp_omit_meta_key_my_custom_field', '__return_true' ); |
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 | |
// prevent 'wide' from being ignored by SearchWP | |
function my_searchwp_common_words( $terms ) { | |
if ( $key = array_search( 'wide', $terms ) ) { | |
unset( $terms[ $key ] ); | |
} | |
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 my_searchwp_index_chunk_size() { | |
// index 5 posts at a time instead of the default 10 | |
return 5; | |
} | |
add_filter( 'searchwp_index_chunk_size', 'my_searchwp_index_chunk_size' ); |
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 | |
/** | |
* USE CASE: I'm building a client site that has 3 main 'sections' | |
* - Portfolio | |
* - About | |
* - Solutions | |
* | |
* Each one of these 'sections' has a Page at the top level, which defines the URI segment | |
* - example.com/portfolio/ |
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 | |
add_filter( 'searchwp_big_selects', '__return_true' ); |
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 | |
/** | |
* Tell WP Views Parametric Search to restrict it's results pool | |
* to what SearchWP finds, based on our custom setup | |
*/ | |
global $doing_searchwp_search; | |
$doing_searchwp_search = false; |
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
<nav> | |
<ul> | |
<li class="nav-about<?php if ( is_page( 83 ) ) : ?> current<?php endif; ?>"> | |
<a href="<?php echo get_permalink( 83 ); ?>">About</a> | |
</li> | |
</ul> | |
</nav> |
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
<nav> | |
<ul> | |
<li class="<?php if( TemplateMap()->maybe_in_section( 'template-about.php' ) ) : ?> current<?php endif; ?>"> | |
<?php $about_page_id = TemplateMap()->get_id_from_template( 'template-about.php' ); ?> | |
<a href="<?php echo get_permalink( $about_page_id ); ?>">About</a> | |
</li> | |
</ul> | |
</nav> |