List just subcategory and products of active category page in Woocommerce

Working on a category page – taxonomy-product_cat.php – I want to list all the subcategories of that category page, with all its products. I would think it is simple enough but I cant get it to work.

I can list all categories of the shop with all subcategories and all products – So for example bags would list all products of the whole shop.

Or I can list the subcategories of just the category page – but without the products listed.

How can I list just the subcategories of the category page with their products?

The code I am using that works great, but loops all the categories in the shop, and not just the active category is:

$  args = array('taxonomy' => 'product_cat' ); $  all_categories = get_categories( $  args );  foreach ($  all_categories as $  cat) {     $  category_id = $  cat->term_id;     $  args2 = array('taxonomy' => $  taxonomy,'parent' => $  category_id,'hierarchical' => $  hierarchical, 'orderby' => $  orderby, 'order' => $  order,'hide_empty' => $  empty); $  categories = get_categories( $  args2 );   $  sub_cats = get_categories( $  args2 );             if($  sub_cats) {                 foreach($  sub_cats as $  sub_category) {                     echo "<h2>".$  sub_category->cat_name."</h2>";                      $  args = array( 'post_type' => 'product','product_cat' => $  sub_category->slug, 'orderby' => $  orderby, 'order' => $  order);                             $  loop = new WP_Query( $  args );                                while ( $  loop->have_posts() ) : $  loop->the_post(); global $  product; ?>                               <!--HTML HERE-->                               <?php endwhile;  wp_reset_query();  }}} ?> 

Get x numbers of a woocommerce category products using Wp_Query

Is possible to show some woocommerce products inside a swiper slider? I want to create a slider that will show some “featured” products on the home page. For now I have a cpt that is achieving this, but I don’t know how to link them to the products that I will add to woocommerce. So I want to replace the cpt with a query to get an x number of products from woocommerce products and put them into the slider. Any help will be appreciated.

The code I’m using now is this

<div class="row featured-row" <?php $  featured = new WP_Query( ['post_type' => 'featured', 'order' => 'ASC', 'posts_per_page' => 3] ); ?> <?php $  i = 0; ?> <?php if( $  featured->have_posts() ): while( $  featured->have_posts() ): $  featured->the_post(); ?> <?php #$  class = get_post_meta( get_the_ID(), 'class', true); ?> <?php if( $  i === 1 ): ?>   <div class="col-md-6 col-lg-6 d-none d-sm-none d-md-block featured-desc">     <h2 class="featured-title-right text-right"><?php the_title(); ?></h2>     <p class="featured-excerpt-right text-right"><?php echo get_the_excerpt(); ?></p>   </div>   <div class="col-md-6 col-lg-6 text-center d-none d-sm-none d-md-block featured-img">     <img class="img-fluid" src="<?php the_post_thumbnail_url(); ?>">   </div> <?php else: ?>   <div class="col-md-6 col-lg-6 text-center d-none d-sm-none d-md-block featured-img">     <img class="img-fluid" src="<?php the_post_thumbnail_url(); ?>">   </div>   <div class="col-md-6 col-lg-6 d-none d-sm-none d-md-block featured-desc">     <h2 class="featured-title"><?php the_title(); ?></h2>     <p class="featured-excerpt"><?php echo get_the_excerpt(); ?></p>   </div> <?php endif;?> <?php $  i++; ?> <?php endwhile; ?> <?php endif; wp_reset_postdata(); ?> </div>  

Custom image dimensions for each category

Hi everyone and happy new year 2020,

I need to set up different image dimensions for each category of a website.

For example,

To set these dimensions for Category 1:

Catalog Images = 240 x 320px
Single Product Image = 470 x 627px
Product thumbnails = 75 x 100px

And these dimensions for category 2:

Catalog Images = 245 x 245px
Single Product Image = 470 x 470px
Product thumbnails = 75 x 75px

I use woocommerce.
How to do this? Is there any code or filter to affect to that a named…

Custom image dimensions for each category

How to remove Author and Category from a single portfolio page?

I have a little issue with removing the Category and Author from my single portfolio pages. I tried different suggestions from other posts here and nothing worked, I also tried to modify the code myself and am hitting a wall again. Apparently it seems the right code to be added is strictly individual depending on the page and I was hoping someone can give me a little nudge. I’am using the Edge theme and there’s the link to one of the pages that I’m trying to work on:

Thank you all in advance!

Show Two custom Post type and their posts on category page

I have Two Custom Post Types “Article ” & “News” and they both use same categories like [ audit , income , tax] . I want when i open audit category page then the post showsn like below: enter image description here

the code i already tried on archieve.php but isnt working:

<?php      $  cats = get_the_category();     $  args = array(         'post_type' => 'articles',         'post__not_in' => array( get_the_ID() ),         'posts_per_page' => 5,         'cat'     => $  cats[0]->term_id,         'meta_query' => array(                     array(                     'key' => 'recommended_article',                     'value' => '1',                     'compare' => '=='                         )                     )     );     $  query = new WP_Query( $  args );  ?>    <?php if( $  query->have_posts() ) : while( $  query->have_posts() ) : $  query->the_post(); ?>     <!--HTML-->  <?php endwhile; endif; wp_reset_postdata(); ?> 

Why maximum-matching algorithm falls into the category of fill-reducing algorithms?

My understanding is that “maximum matching” (or “maximum transversal”) are algorithms to pre-order matrix to increase the numerical stability. In Timothy Davis’ book Direct Methods for Sparse Linear Systems, 2006, however, this algorithm is put in Chapter 7 which is titled “Fill-reducing ordering”. In his more recent paper A survey of direct methods for sparse linear systems, 2016, maximum matching was also placed in section 8 which is titled “Fill-reducing orderings”.

So far, my had an impression that reordering algorithms can be categorized into 3 classes:

  • for numerical stability: maximum transversal, etc
  • for fill-reducing: AMD, etc
  • for work-reducing or parallelism-increasing: BTF, BBD, etc

I have problems in understanding putting above 3 classes into a single category called fill-reducing…

What category does questions like “Given n points on 2D plane find …” belong to

Not after a specific answer, do following questions belong to same set of problem types?

Given n points in on 2D plane, find 4 or 5 , or m subset of points with less total distant to each other than all other points.


Given n points in on 2D plane, count the number of triangles, squares etc. that they form.


Given n points in on 2D plane, find a point that is closeses to most number of points as possible.

are these optimisation questions? or is there another name for above type of questions, or there can be no category for all the questions of type

Given n points in on 2D plane, find $ \cdots$

This question did not seem to be fit for SO or Software engineering, so I am asking it here, if there is better SE to ask this question I’ll delete this question and ask it there ( in reverse order ).