Support » Plugin: A-Z Listing » List of out of stock products in Woocommerce

  • Hello,

    First of all, thank you very much for such a good plugin.

    The doubt I have is: I use the following shortcode to show products:
    [a-z-listing post-type=”product”]

    But it also shows the products that have stock 0.

    Is it possible that products with stock 0 do not appear?

    Thank you very much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Daniel Llewellyn


    You could try to modify the query used by the plugin by adding some code to your theme’s functions.php similar to below:

    add_filter( 'a_z_listing_query', 'override_az_in_stock_products_only' );
    function override_az_in_stock_products_only( $query, $type = 'posts' ) {
      if ( $type !== 'posts' ) {
        return $query;
      $meta_query = array(
          'key' => '_stock_status',
          'value' => 'instock',
      if ( ! $query instanceof WP_Query ) {
        $query = (array) $query;
      if ( $query instanceof WP_Query && $query->post_type === 'product' ) {
        $query->meta_query = $meta_query;
      } elseif ( $query['post_type'] === 'product' ) {
        $query['meta_query'] = $meta_query;
      return $query;

    I’ve not tested this, but I think it will work. Please give it a try and let me know if it needs improvement that I can help with 🙂

    Thank you so much for answering the question and for your help.

    I tried to paste the code into the functions.php file but it doesn’t seem to be working, out of stock products appear in the list.

    Maybe I have to do something else (I just pasted the code in functions.php to my theme). I’m not a php programmer and I don’t know the internal workings of wordpress.

    The theme I use is storefront with an empty child theme.

    Thanks and sorry for the inconvenience.

    Plugin Author Daniel Llewellyn


    I’ll try to find some time to experiment to see if I can work out a solution for you 🙂

    Plugin Author Daniel Llewellyn


    in fact, I immediately see a mistake in my code – the third line has:

      if ( $type !== 'posts' ) {

    but it should read:

      if ( $type !== 'product' ) {
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.