Can’t filter out variable products in sale from wp_get_products loop (or shortcode) [closed]

Ok, after some digging around I’ve finally found the answer I was looking for. Turns out there is a function called wc_get_product_ids_on_sale() you can use to exclude those ID’s from wc_get_products. So for anyone having the same problem.. you can use ‘exclude’ => wc_get_product_ids_on_sale() within your wp_get_products args and you’re all set!

Get posts that do not have the same tags as current

I found an answer to my own question: If I use the tax_query arg then I could specify ‘operator’ => ‘NOT IN’ like so: $events = tribe_get_events([ ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘name’, ‘terms’ => $current_tag, ‘operator’ => ‘NOT IN’ // HERE ) ), ‘start_date’ => ‘now’, ‘eventDisplay’ => ‘list’, ‘posts_per_page’ … Read more

How to create custom popup in shop page on every loop products?

Use below code. Tested and Worked perfectly. functions.php add_action( ‘woocommerce_after_shop_loop_item’, ‘product_visibility_button’, 5 ); function product_visibility_button() { if ( is_user_logged_in() ) { $user = wp_get_current_user(); if ( in_array( ‘administrator’, (array) $user->roles ) ) { ?> <button type=”button” class=”button” id=”but” style=”margin:10px” >Open Popup</button> <div style=”display: none;” class=”pop-outer”> <div class=”pop-inner”> <button class=”close”>X</button> <h2>This is a custom pop-up example</h2> … Read more

Multisite foreach loop returning only one result

Each pass through the foreach() loop, you’re wiping out the values that are already in your $urls array. Try something like this: function rel_alternate_network(){ global $post; $slugX = is_main_site() ? $post->post_name : rtrim($post->post_name, ‘-in-‘.strtolower(do_shortcode(‘[country]’))); $urls = array(); foreach(get_sites() as $site){ if( $site->blog_id == get_current_blog_id()) {continue;} switch_to_blog($site->blog_id); $slugY = get_post_by_slug($slugX); $new_url[‘site’] = $site->path; $new_url[‘slug’] = $slugY->post_name; … Read more

Loop increase in while loop not working

You’re reassigning 1 to $i on every loop: if ( $i = 1) { This should be if ( $i == 1) { or even if ( $i === 1) { which will also compare the post type, which is best practice. In PHP, = is assignment, == is comparison: