If I don't have posts in a category, the category.php file won't load. This is a problem, because whoever built this custom template, used post categories to display woocommerce prodcuts (don't ask why or how) ...

How could I force wordpress to load the template file, even if the category has no posts?

$args = array(
     'post_type' => 'product',
     'cat' => get_queried_object()->cat_ID,
     /* ... */
$products = query_posts($args);

This is the code that loads the products, included in category.php

  • Are you sure you meant category and not product category? The distinction is very important, if it's a product category then it should never lad category.php. Keep in mind that there's a very high chance this question is offtopic as WooCommerce and other 3rd party plugins are offtopic and not in this stacks scope. We would need more information about how this is set up to determine that, and to identify what's going on here. – Tom J Nowell Jul 6 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.