Display children and grandchildren of a custom post type

You can create walker for the wp_list_pages() this function use the Walker_Page you can extends him. Walker fo example you put it in the functions.php I added comments with the class name No_Link_First_Child_Walker so you could see what I changed you can search for them. class No_Link_First_Child_Walker extends Walker_Page { public function start_el( &$output, $page, … Read more

Get product list of given category

In the end my main problem turned out to be that I was executing code right into functions.php (for testing purpose). The code was executing before woocommerce was initialized and then was failing to fetch products correctly. Despite that, I couldn’t get Wp_Query to return only products of one given category. It was still returning … Read more

Advanced WP Query hogs the SQL server

There are several options: Use some Lucene-based search index and cache your queries there. Power it with lots of RAM so nothing hits your DB after the first query. Use something like… Elasticsearch Solr Sphinx Do not attempt to run Lucene plain … you will find yourself in hell. Nobody does that for a good reason. … Read more

Use meta_query to display events by date in custom field

Simpler CODE: Logically, when you check >= for both _event_start_date and _event_end_date, that automatically covers the BETWEEN check. So the following CODE should work: $termName = get_queried_object()->name; $termSlug = get_queried_object()->slug; $event1 = current_time( ‘Y-m-d’ ); $args = array( ‘post_type’ => ‘event’, ‘event-categories’ => $termSlug, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 10, ‘order’ => ‘ASC’, ‘meta_query’ => … Read more

get complex results set according to category structure

Thinking aloud here… $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘term_id’, ‘terms’ => array( 202, 203 ), ‘include_children’ => 1, ), array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘term_id’, ‘terms’ => array( 100 ), ‘include_children’ => false, ) ), ), ); … Read more