Getting the post terms ‘wp_get_post_terms’ per post when within the functions.php file

(Revised answer) So I’m assuming that there are actually posts in the category (ID: 31), and based on the wp_get_post_terms() reference: $post_id (int) (Optional) The Post ID. Does not default to the ID of the global $post. Default 0. It’s likely that you’re not passing the proper post ID to the wp_get_post_terms() function: wp_get_post_terms( $post->ID, … Read more

Woo Commerce using WP_Query to get products that match price range, with an additional required product attribute

Your mixing up your meta query and tax query. try this: $params = array( ‘posts_per_page’ => 20, ‘post_type’ => array(‘product’, ‘product_variation’), ‘meta_query’ => array( array( ‘key’ => ‘_price’, ‘value’ => $_POST[‘product_price_min’], ‘compare’ => ‘>=’, ‘type’ => ‘NUMERIC’ ), array( ‘key’ => ‘_price’, ‘value’ => $_POST[‘product_price_max’], ‘compare’ => ‘<=’, ‘type’ => ‘NUMERIC’ ), ), ‘tax_query’ => … Read more

WP_QUERY wrong ammount of posts

But all of them get obtained from the database. The problem is that you’re ignoring half of them. Or rather merging two of them and displaying as one. Let’s take a look at your code: while ( $query->have_posts() ) { $query->the_post(); // <- here you call the_post() first time $output.='<div class=”entry filter_product”>’; // and in … Read more

AJAX Breaking Offset Argument In WP Query

So I’m guessing this is a follow-up to this question. And based on my answer there, you can use/add the offset parameter like so: In category.php, just set the preferred offset: $the_query = new WP_Query( array( ‘category__in’ => array( $cat_id ), ‘post_type’ => ‘post’, ‘posts_per_page’ => 5, ‘paged’ => $current_page, ‘offset’ => 1, // set … Read more