Woocommerce show product published date on shop page [closed]

…衆ロ難τιáo~ 提交于 2021-02-08 12:13:13

问题


I'm looking for solution to display products published date on shop page.

I would very greatful for any help.


回答1:


Show Product Published Date Shop and Single Page in WooCommerce

add the below function in function.php file

  //WooCommerce Shop Page : Show Product Published Date
    add_action( 'woocommerce_after_shop_loop_item', 'wc_shop_page_product_date', 100 );
    function wc_shop_page_product_date() {
        echo the_date('', '<span class="date_published">Published on: ', '</span>', false);
    }

    //WooCommerce Single Page : Show Product Published Date
    add_action('woocommerce_single_product_summary','wc_single_page_product_date',25);
    function wc_single_page_product_date() {
        if (is_product() ) {
            echo the_date('', '<span class="date_published">Published on: ', '</span>', false);
        }
    }



回答2:


add_action('woocommerce_single_product_summary','show_product_date',28);
function show_product_date() {
  if (is_product() ) {
    echo the_date('', '<p class="product_date">Published on: ', '</p>', false);
  } 
}


来源:https://stackoverflow.com/questions/44627695/woocommerce-show-product-published-date-on-shop-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!