Skip to main content
Commonmark migration
Source Link

You have used woocommerce_after_shop_loop action hook which is within the following condition:

<?php if ( have_posts() ) : ?>

You should use woocommerce_after_main_content in order to display your data. Because it is outside of this condition. Your data will display even there are no products in the category.

UPDATE:

You can add condition to your custom function so that data will display only if the page is category.

Read this on how to use conditions for WooCommerce:

Some from there:

is_product_category()

 

Returns true when viewing a product category archive.

 

is_product_category( 'shirts' )

 

When the product category page for the ‘shirts’ category is being displayed.

 

is_product_category( array( 'shirts', 'games' ) )

 

When the product category page for the ‘shirts’ or ‘games’ category is being displayed.

So you can update your code as follows:

if ( $term_meta_content != '' && is_product_category()) {
    echo '<h2 style="text-align:center; font-weight:bold;">Local info</h2><div class="term-description"><p>';
      echo apply_filters( 'the_content', $term_meta_content );
    echo '</p></div>';
  }

You have used woocommerce_after_shop_loop action hook which is within the following condition:

<?php if ( have_posts() ) : ?>

You should use woocommerce_after_main_content in order to display your data. Because it is outside of this condition. Your data will display even there are no products in the category.

UPDATE:

You can add condition to your custom function so that data will display only if the page is category.

Read this on how to use conditions for WooCommerce:

Some from there:

is_product_category()

 

Returns true when viewing a product category archive.

 

is_product_category( 'shirts' )

 

When the product category page for the ‘shirts’ category is being displayed.

 

is_product_category( array( 'shirts', 'games' ) )

 

When the product category page for the ‘shirts’ or ‘games’ category is being displayed.

So you can update your code as follows:

if ( $term_meta_content != '' && is_product_category()) {
    echo '<h2 style="text-align:center; font-weight:bold;">Local info</h2><div class="term-description"><p>';
      echo apply_filters( 'the_content', $term_meta_content );
    echo '</p></div>';
  }

You have used woocommerce_after_shop_loop action hook which is within the following condition:

<?php if ( have_posts() ) : ?>

You should use woocommerce_after_main_content in order to display your data. Because it is outside of this condition. Your data will display even there are no products in the category.

UPDATE:

You can add condition to your custom function so that data will display only if the page is category.

Read this on how to use conditions for WooCommerce:

Some from there:

is_product_category()

Returns true when viewing a product category archive.

is_product_category( 'shirts' )

When the product category page for the ‘shirts’ category is being displayed.

is_product_category( array( 'shirts', 'games' ) )

When the product category page for the ‘shirts’ or ‘games’ category is being displayed.

So you can update your code as follows:

if ( $term_meta_content != '' && is_product_category()) {
    echo '<h2 style="text-align:center; font-weight:bold;">Local info</h2><div class="term-description"><p>';
      echo apply_filters( 'the_content', $term_meta_content );
    echo '</p></div>';
  }
added 366 characters in body
Source Link

You have used woocommerce_after_shop_loop action hook which is within the following condition:

<?php if ( have_posts() ) : ?>

You should use woocommerce_after_main_content in order to display your data. Because it is outside of this condition. Your data will display even there are no products in the category.

UPDATE:

You can add condition to your custom function so that data will display only if the page is category.

Read this on how to use conditions for WooCommerce:

Some from there:

is_product_tagis_product_category()

Returns true when viewing a product tagcategory archive.

is_product_tagis_product_category( 'shirts' )

When the product tagcategory page for the ‘shirts’ tagcategory is being displayed.

is_product_tagis_product_category( array( 'shirts', 'games' ) )

When the product tagcategory page for the ‘shirts’ or ‘games’ tagscategory is being displayed.

So you can update your code as follows:

if ( $term_meta_content != '' && is_product_category()) {
    echo '<h2 style="text-align:center; font-weight:bold;">Local info</h2><div class="term-description"><p>';
      echo apply_filters( 'the_content', $term_meta_content );
    echo '</p></div>';
  }

You have used woocommerce_after_shop_loop action hook which is within the following condition:

<?php if ( have_posts() ) : ?>

You should use woocommerce_after_main_content in order to display your data. Because it is outside of this condition. Your data will display even there are no products in the category.

UPDATE:

You can add condition to your custom function so that data will display only if the page is category.

Read this on how to use conditions for WooCommerce:

Some from there:

is_product_tag()

Returns true when viewing a product tag archive

is_product_tag( 'shirts' )

When the product tag page for the ‘shirts’ tag is being displayed.

is_product_tag( array( 'shirts', 'games' ) )

When the product tag page for the ‘shirts’ or ‘games’ tags is being displayed.

You have used woocommerce_after_shop_loop action hook which is within the following condition:

<?php if ( have_posts() ) : ?>

You should use woocommerce_after_main_content in order to display your data. Because it is outside of this condition. Your data will display even there are no products in the category.

UPDATE:

You can add condition to your custom function so that data will display only if the page is category.

Read this on how to use conditions for WooCommerce:

Some from there:

is_product_category()

Returns true when viewing a product category archive.

is_product_category( 'shirts' )

When the product category page for the ‘shirts’ category is being displayed.

is_product_category( array( 'shirts', 'games' ) )

When the product category page for the ‘shirts’ or ‘games’ category is being displayed.

So you can update your code as follows:

if ( $term_meta_content != '' && is_product_category()) {
    echo '<h2 style="text-align:center; font-weight:bold;">Local info</h2><div class="term-description"><p>';
      echo apply_filters( 'the_content', $term_meta_content );
    echo '</p></div>';
  }
added 120 characters in body
Source Link

You have used woocommerce_after_shop_loop action hook which is within the following condition:

<?php if ( have_posts() ) : ?>

You should use woocommerce_after_main_content in order to display your data. Because it is outside of this condition. Your data will display even there are no products in the category.

UPDATE:

You can add condition to your custom function so that data will display only if the page is category.

Read this on how to use conditions for WooCommerce:

Some from there:

is_product_tag()

Returns true when viewing a product tag archive

is_product_tag( 'shirts' )

When the product tag page for the ‘shirts’ tag is being displayed.

is_product_tag( array( 'shirts', 'games' ) )

When the product tag page for the ‘shirts’ or ‘games’ tags is being displayed.

You have used woocommerce_after_shop_loop action hook which is within the following condition:

<?php if ( have_posts() ) : ?>

You should use woocommerce_after_main_content in order to display your data. Because it is outside of this condition. Your data will display even there are no products in the category.

You have used woocommerce_after_shop_loop action hook which is within the following condition:

<?php if ( have_posts() ) : ?>

You should use woocommerce_after_main_content in order to display your data. Because it is outside of this condition. Your data will display even there are no products in the category.

UPDATE:

You can add condition to your custom function so that data will display only if the page is category.

Read this on how to use conditions for WooCommerce:

Some from there:

is_product_tag()

Returns true when viewing a product tag archive

is_product_tag( 'shirts' )

When the product tag page for the ‘shirts’ tag is being displayed.

is_product_tag( array( 'shirts', 'games' ) )

When the product tag page for the ‘shirts’ or ‘games’ tags is being displayed.

Source Link
Loading