Using Transients

I have set set_transient( ‘pgggo_acf_list_transient’, $pgggo_qry, 12 * 7000 ); is that too high? 12 * 7000 is just over 23 hours. Whether or not that’s too high (or low) depends entirely on your specific needs. The expiry time should be based on how often the data needs to be refreshed. What if there is … Read more

WP_Query order by not working properly due to category I believe

I manage to fixed this the problem was type => ‘numeric’ $query = new WP_Query( array( ‘post_type’ => post, ‘posts_per_page’ => -1, ‘category_name’ => $category, ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘price_clause’ => array( ‘key’ => ‘price’, ‘type’ => ‘numeric’, ‘compare’ => ‘EXISTS’ ), ‘external_clause’ => array( ‘key’ => ‘external_link’, ‘compare’ => ‘EXISTS’ ) ), … Read more

How to add tax_query to $args with concatenation

Try this… <?php if ( $value[ ‘priceRange’ ] == 0 && $value[ ‘tags’ ] == 0 && !$value[ ‘type’ ] ) { if ( !$value[ ‘priceRange’ ] ) { $value[ ‘priceRange’ ] = array( 0, 1000000 ); } $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => -1, ); } if ( $value[ ‘priceRange’ ] == … Read more

How do I get Woocommerce product variation name and variation description in a WP_Query?

OK, so soon after posting I came up with a working solution. With this code I get the price straight from the variation price field, not from the description field as I mentioned in my question. <?php $params = array(‘posts_per_page’ => -1, ‘post_type’ => ‘product_variation’, ‘order’ => ‘ASC’); $wc_query = new WP_Query($params); global $product; ?> … Read more

Multiple wordpress queries with nested output (odd – even)

Why not just do straight what you’ve wanted. <?php $args_one = array( ‘cat’ => 7, ‘posts_per_page’ => 8, ); $args_two = array( ‘cat’ => 10, ‘posts_per_page’ => 8, ); // will run 2 sql queries. $posts_one = get_posts( $args_one ); $posts_two = get_posts( $args_two ); $all_posts = array(); // lets merge them into 1 array. … Read more

wp_trim_words strips dashicons

Your problem is that your filter is trimming all titles to 7 “words”. This includes blog posts, pages, menu item labels, revision names, and even product names, if you have products. You need to adjust your filter to be less aggressive and only target the titles that you need to truncate. For example, the following … Read more

Limit number of posts in loop

I consider the right way could be filtering of total number of found posts like this. function my_custom_found_posts_limiter( $found_posts, $wp_query ) { $maximum_of_post_items = 100; // place your desired value here or read if from option\setting. if ( ! is_admin() && $wp_query->is_main_query() && $wp_query->is_post_type_archive( ‘blog_posts’ ) ) { if ( $found_posts > $maximum_of_post_items ) { … Read more