Plugin Author
Ajay
(@ajay)
I’m not familiar with ACF, but you’ll need to do a bit of coding to get this to work. Here is an example of a filter I used for getting this to work with WooCommerce and limiting it to only visible products.
https://gist.github.com/ajaydsouza/767215093a24bafb903a
This uses a custom meta field to make it work
Hello,
thank you for your answer.
I have added this code to function.php and adapted it but it doesn’t seem to be used by the plugin.
I event put some prints inside and they are not printed.
What do I do Wrong ?
Thank you,
Renato
-
This reply was modified 9 years, 1 month ago by
art2com.
Plugin Author
Ajay
(@ajay)
You can’t use the code as is. You’ll need to modify this for your custom meta field to check if that custom field exists. Frankly, it’s quite a bit of advanced coding to get the custom field to work so easily.
Hello,
thank you for your help.
The display problem was due to the cache. We have disabled it and it works.
Here is the code working :
/**
* Joins the Post Meta table. Filters bsearch_posts_join.
*
* @param string $join
* @return string
*/
function filter_bsearch_posts_join( $join ) {
global $wpdb;
$new_join = $join . “INNER JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)”;
return $new_join;
}
add_filter( ‘bsearch_posts_join’, ‘filter_bsearch_posts_join’ );
/**
* Checks the ‘_visibility’ meta key for ‘visible’ meta_value. Filters bsearch_posts_where.
*
* @param string $join
* @return string
*/
function filter_bsearch_posts_where( $where ) {
global $wpdb;
$new_where = $where . ” OR ( wpit_posts.post_status IN (‘publish’, ‘future’) AND ( $wpdb->postmeta.meta_key = ‘numero_post’ AND $wpdb->postmeta.meta_value = ‘”. get_search_query() . “‘ ))”;
return $new_where;
}
add_filter( ‘bsearch_posts_where’, ‘filter_bsearch_posts_where’ );
Have a great day,
Renato
Plugin Author
Ajay
(@ajay)
Thanks for the update and the code. It should help any other users as well with ACF.