Skip to main content
Source Link
Randomer11
  • 416
  • 11
  • 31

Display data when category is empty

I have the following code which inserts data to the bottom of a product category. It works perfectly however it only displays when a product is actually in the category, id like it to display in empty categories too. What am I doing wrong ?

    add_action( 'woocommerce_after_shop_loop', 'wpm_product_cat_archive_add_meta' );
function wpm_product_cat_archive_add_meta() {
  $t_id = get_queried_object()->term_id;
  $term_meta = get_option( "taxonomy_$t_id" );
  $term_meta_content = $term_meta['custom_term_meta'];
  if ( $term_meta_content != '' ) {
    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>';
  }
}