Seach custom post type posts only by meta fields?

This might work, not tested though. First add this to join the postmeta table: add_filter( ‘posts_join’, ‘search_filters_join’, 501, 2 ); function search_filters_join( $join, $query ) { global $wpdb; if ( empty( $query->query_vars[ ‘post_type’ ] ) || $query->query_vars[ ‘post_type’ ] !== ‘product’ ) { return $join; // skip processing } if ( ($this->is_ajax_search() || $this->is_search_page()) && … Read more

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

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