mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-28 11:22:21 +08:00
9 lines
429 B
Text
9 lines
429 B
Text
add_filter( 'relevanssi_indexing_restriction', 'non_product_attachments' );
|
|
function non_product_attachments( $restriction ) {
|
|
global $wpdb;
|
|
$restriction['mysql'] .= " AND post.ID NOT IN (
|
|
SELECT ID FROM $wpdb->posts
|
|
WHERE post_type = 'attachment' AND post_parent NOT IN ( SELECT ID FROM $wpdb->posts WHERE post_type = 'product' ) ) ";
|
|
$restriction['reason'] .= ' Non-product attachment';
|
|
return $restriction;
|
|
}
|