How can I get the values of my WordPress $wpdb query in Jquery?

I was able to solve this by using the WooCommerce api with only jQuery. $(“.check-zip”).on(‘click’, function () { var zipCode = jQuery(“#custom_zip”).val(); var zipArray = []; var url = WPURLS.template_url; $(“.zip-msg”).remove(); $.ajax({ type: ‘GET’, url: url + ‘/wp-json/wc/v2/shipping/zones/1/locations’, dataType: “json”, data: { type: ‘postcode’ }, beforeSend: function (xhr) { xhr.setRequestHeader(‘X-WP-Nonce’, wpApiSettings.nonce); }, success: function (data) … Read more

Nested shortcode functions accessing variable

After a bit of lateral thinking and lots of testing I was able to come up with a solution that negated the need for scope crossing variables, or using a global variable for that matter. The code goes like this: Split the nested $content(nested shortcodes) into single shortcodes with preg_match_all Apply do_shortcode to each shortcode … Read more

selected option if current category is the value

The problem is how you’ve used selected(). That function outputs selected=”selected” if the first argument matches the second argument. So what you’re doing is marking the option as selected if: (string) ‘https://premium.wpmudev.org/blog/category/news-community/’ === (string) true Which – because the values are cast as strings and compared with === – will never be true, even if … Read more

Return a numerical function value in Customizer controls

The solution for me ended up being to simply remove the np_post_num() add_action hook altogether, and instead declare get_theme_mod() as the desired variable $option_pg_number. This allowed use of the returned number variable in a separate loop function controlled by $option_pg_number, instead of just printing the returned number value of ‘np_posts_per_page’ on the page. $option_pg_number = … Read more