title: How to display sales date in woocommerce
body: <p>In Woocommerce, I am trying to display the sales date of a variable product.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/40711914/display-sale-date-from-and-sale-date-to">a code</a>, if I post this code exactly in functions.php it doesn't do anything. I tried to modify it, because I need it only on the start page, but the <code>var_dump</code> returns an empty string. Maybe I have to add an argument?</p>
  
  <pre><code>&lt;?php
  $meta_query  = WC()-&gt;query-&gt;get_meta_query();
  $tax_query   = WC()-&gt;query-&gt;get_tax_query();
  $tax_query[] = array(
      'taxonomy' =&gt; 'product_visibility',
      'field'    =&gt; 'name',
      'terms'    =&gt; 'featured',
      'operator' =&gt; 'IN',
  );
  
  $args = array(
      'post_type'           =&gt; 'product',
      'post_status'         =&gt; 'publish',
      'posts_per_page'      =&gt; 1,
      'meta_query'          =&gt; $meta_query,
      'tax_query'           =&gt; $tax_query,
  );
  
  $featured_query = new WP_Query( $args );
  if ($featured_query-&gt;have_posts()) {
      while ($featured_query-&gt;have_posts()) : 
  
          $featured_query-&gt;the_post();         
          $product = get_product( $featured_query-&gt;post-&gt;ID );
          $price = $product-&gt;get_price_html();            
          $sales_price_from = get_post_meta( $product-&gt;id, '_sale_price_dates_from', true );
          $sales_price_to   = get_post_meta( $product-&gt;id, '_sale_price_dates_to', true );
          $sales_price_date_from = date( "j.m.Y", $sales_price_from );
          $sales_price_date_to   = date( "j.m.Y", $sales_price_to );
          $sales_date = '&lt;p class="offer_date"&gt;Angebot vom '.$sales_price_date_from.' bis '.$sales_price_date_to.'&lt;/p&gt;';
          ?&gt;
  
          &lt;div class="wochenangebot"&gt; 
          &lt;h2&gt;Wochenangebot&lt;/h2&gt;
              &lt;div class="wochenangebot_content"&gt;
              &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;
                  &lt;h3&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt;
                  &lt;?php echo $sales_date; ?&gt;
                  &lt;?php var_dump($sales_price_to) ?&gt;
                  &lt;?php the_content(); ?&gt;
              &lt;/a&gt;
              &lt;span class="price"&gt;&lt;?php echo $price; ?&gt;&lt;/span&gt;
  
              &lt;div class="legal-price-info"&gt;
              &lt;p class="wc-gzd-additional-info"&gt;
                  &lt;span class="wc-gzd-additional-info tax-info variation_modified" style="display: inline;"&gt;inkl. MwSt.&lt;/span&gt;
                  &lt;span class="wc-gzd-additional-info shipping-costs-info variation_modified" style="display: inline;"&gt;zzgl. &lt;a href="https://nussundgenuss.de/unser-service/" target="_blank"&gt;Versandkosten&lt;/a&gt;&lt;/span&gt;
              &lt;/p&gt;
          &lt;/div&gt;  
              &lt;a class="button" href="&lt;?php the_permalink(); ?&gt;"&gt;Hol es dir&lt;/a&gt;
              &lt;/div&gt;
              &lt;aside&gt;
              &lt;?php 
                  if ( has_post_thumbnail( $loop-&gt;post-&gt;ID ) ) 
                      echo get_the_post_thumbnail( $loop-&gt;post-&gt;ID, 'shop_catalog' ); 
                  else 
                      echo '&lt;img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" &gt;'; 
              ?&gt;
              &lt;/aside&gt;
          &lt;/div&gt;
  
  &lt;?php   endwhile;
  }
  ?&gt;  
  </code></pre>
  
  <p>Any help is really appreciated.</p>