Skip to content

Instantly share code, notes, and snippets.

@Bobz-zg
Last active February 27, 2017 16:16
Show Gist options
  • Save Bobz-zg/5e73b4cc05f30ddd6a030154563359bd to your computer and use it in GitHub Desktop.
Save Bobz-zg/5e73b4cc05f30ddd6a030154563359bd to your computer and use it in GitHub Desktop.
Include password protected products in WooCommerce search results for non-logged in users
<?php
/**
* Place this part of code somewhere in functions.php
*/
add_filter( 'posts_where' , function($q) {
global $wpdb;
$r = "AND ({$wpdb->posts}.post_password = '')";
$q = str_replace($r, '', $q);
return $q;
}, 1001 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment