Skip to content

Instantly share code, notes, and snippets.

@joebasurto
Last active June 15, 2019 06:54
Show Gist options
  • Save joebasurto/c8959c7aa355fb029193913ba93e2647 to your computer and use it in GitHub Desktop.
Save joebasurto/c8959c7aa355fb029193913ba93e2647 to your computer and use it in GitHub Desktop.
<?php
/*
* Searchable Ecwid products add to functions.php
*/
// Pre post hook, query modifier
add_filter('pre_get_posts', 'tgm_io_cpt_search');
// Modifier function
function tgm_io_cpt_search($query) {
if ($query->is_search) {
// Add ec-product post type; will also except other custom post types
$query->set('post_type', array('ec-product'));
}
// Return result
return $query;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment