Custom Query to search through categories

It sounds like you’re looking for the get_terms() function that’s a wrapper for WP_Term_Query. There you can e.g. use the name__like, description__like or search parameters. Example: Here’s what kind of WHERE query they generate: ‘name__like’ => ‘hout’ >>> (t.name LIKE ‘%hout%’) ‘description__like’ => ‘hout’ >>> tt.description LIKE ‘%hout%’ ‘search’ => ‘hout’ >>> (t.name LIKE ‘%hout%’) … Read more

When using get_categories or similar, is it possible to filter results that contain certain Tags as well?

Check out my answer on how to get terms that are associated with others through the posts that they’re attached to. In your case, you could put it into practice like so; $category_IDs = get_terms_soft_associated( ‘category’, array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => ‘audio’ ) ); wp_list_categories( array( ‘include’ => $category_IDs ) ); … Read more

Show children of top level category only

Ok, try this. It should capture the current category object and then go up the chain until it finds the current categories top-most ancestor. // get the category object for the current category $thisCat = get_category( get_query_var( ‘cat’ ) ); // if not top-level, track it up the chain to find its ancestor while ( … Read more

Category Archive, list subcategories of each post

If you want to list only child categories of the current category, set the child_of argument to the current category ID. wp_list_categories( array( ‘child_of’ => get_queried_object_id(), // this will be ID of current category in a category archive ‘style’ => ‘none’, ‘title_li’ => ” ) ); EDIT- To list only child categories per-post of the … Read more

WordPress: category page not for post’s

Add the ‘post_type’ parameter in your query args (‘post_type’ => ‘game’): <?php if (is_page() ) { $category = get_post_meta($posts[0]->ID, ‘category’, true); } if ($category) { $cat = get_cat_ID($category); $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $post_per_page = 4; // -1 shows all posts $do_not_show_stickies = 1; // 0 to show stickies $args=array( ‘post_type’ => ‘game’, … Read more