Woocommerce – Filter Variable Products by Variation Attributes and Variations Regular Price

So, I finally figured out the answer… This may help someone in future. Here is the query that will first filter variable products for attribute Quantity which has term id 75 and then it will further filter result for variations which has price 500 set. $query = array( ‘post_status’ => ‘publish’, ‘post_type’ => array(‘product’, ‘product_variation’), … Read more

Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce

Look into wp_set_object_terms() You could do something along the lines of: wp_set_object_terms( $post_id, ‘exclude-from-catalog’, ‘product_visibility’ ); Getting all posts by status, use Wp_Query. I added the ‘fields’ => ‘ids’ param to limit the query to only ids, rather than gathering whole post objects. On an array of posts that have Draft or Pending as a … Read more

Parsing php string in jquery [closed]

Well it seems @JacobPeattie mentioned to use json, I just echoing that. First json encode the variable $array = json_encode($out); Then send this value echo ‘<div data-ad = ‘.$array.’ class=”ash_loadmore”><span>LOAD MORE</span></div>’; To get that echo json_encode($_POST[‘ad’]) I think that’s it.BTW you don’t have now that string problem as the output will be like this {“footer-insta”:2,”sidebar-1″:3} … Read more

Shortcode return function with link href inside PHP

You can use ob_start and ob_get_clean to print out your shortcode. function shortcode_html() ob_start(); ?> <div class=”boxed max-width”> <div class=”indice-title”> <span><?php echo $content; ?></span> <i class=”fa fa-twitter” aria-hidden=”true”></i> </div> </div> <?php return ob_get_clean(); } add_shortcode( ‘print_shortcode’, ‘shortcode_html’ );

How can I generate random numbers inside my shortcodes on each implementation?

According to @Mark Kaplun comment: Make your getRandomCode() return value instead of echo like this function getRandomCode(){ $alphanumeric = “0123456789abcdefghijklmnopqrstuvwxyz”; $su = strlen($alphanumeric) – 1; // echo ‘<br/>’; // // echo rand(0, $su); // // echo ‘<br/>’; // // echo substr($alphanumeric, rand(0, $su), 3); // // echo ‘<br/>’; return substr($alphanumeric, rand(0, $su), 3) . substr($alphanumeric, … Read more

An unwanted inline style is added to my body tag

After searching a lot, I realized that elements inside my head tag are shown inside body tag and head tag contains nothing in my generated HTML code. This happened because I had used UTF-8-BOM encoding and by changing it to simple UTF-8 everything was fixed.