Created
April 2, 2014 12:21
-
-
Save mauryaratan/9933024 to your computer and use it in GitHub Desktop.
Make your WordPress site use WooCommerce product archives search pages by default.
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 crux_search_filter( $query ) { | |
if ( $query->is_search ) { | |
$query->set( 'post_type', 'product' ); | |
$query->is_archive = true; | |
$query->is_post_type_archive = true; | |
} | |
return $query; | |
} | |
add_filter( 'pre_get_posts', 'crux_search_filter' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mauryaratan Hi I'm looking for this exact functionality however when I add this it does return the WooComerce archive but no products. Can you help me get this working?
Thanks