Search in multiple specific post types

I recently had a similar problem and it had something to do with the query’s posts_per_page parameter. Try setting it explicitly, like so: function custom_search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set(‘posts_per_page’, 10 ); // Try setting it to the number you’ve set in the WordPress admin (Settings > Reading). … Read more

Many to many relationship for variable products

a. If your fine with a plugin dependency, ACF has this kind of functionality built in with the “Relationship” field. Relationship: https://www.advancedcustomfields.com/resources/relationship/ Reverse Query: https://www.advancedcustomfields.com/resources/querying-relationship-fields/ b. If you want to do this with just WP core, you would use custom fields. First, on the child product, store the IDs of the product pages it should … Read more

Click Count on Download a File

Use this code.. $downloads = $product->get_files(); $product_id = $product->id; foreach( $downloads as $key => $each_download ) { $query = “SELECT SUM( download_count ) AS count FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE product_id = $product->id”; $count = $wpdb->get_var( $query ); if ( ! empty( $count ) ) { echo ‘<a href=”‘.$each_download[“file”].'”>Download (‘.$count.’)</a>’; } else { echo ‘<a href=”‘.$each_download[“file”].'”>Download</a>’; } … Read more