我對電子商務網站2位所使用的ID和第二步行展示產品下面的代碼簡碼,以顯示產品按類別woocommerce
[Products ids="1, 2, 3, 4, 5"]
[Products skus="foo, bar, baz" orderby="date" order="desc"]
一個。我想用類別展示該產品,但我無法找到此任何快捷方式。
E.g[products product_cat="shoes"]
誰能幫助我?
我對電子商務網站2位所使用的ID和第二步行展示產品下面的代碼簡碼,以顯示產品按類別woocommerce
[Products ids="1, 2, 3, 4, 5"]
[Products skus="foo, bar, baz" orderby="date" order="desc"]
一個。我想用類別展示該產品,但我無法找到此任何快捷方式。
E.g[products product_cat="shoes"]
誰能幫助我?
你嘗試這樣的: 產品類別按彈頭
這將輸出簡碼:[[[PRODUCT_CATEGORY類=」」 per_page =」 12「列=」 4」排序依據=」日期」爲了= 「降序」]]]。與產品類別類似,但這會輸出指定類別內的所有產品,並且可以使用per_page =「」和columns =「」參數進行排列。通過導航到WP管理員的產品菜單並點擊類別,您將看到所有可用類別和相應的slu list的列表,可以找到類別slu g。
見其中有選項也
請參閱此鏈接也更多簡碼下面的圖片:https://gplclub.org/woocommerce-shortcodes-full-list/
謝謝rahul。我認爲[product_category -----]用於顯示類別列表:),但謝謝 – user3501409
此鏈接已過時。這裏是如何做到這一點... [product_category category =「truck-parts」] https://www.tytonmedia.com/blog/woocommerce-shortcodes-list/ – tytyguy
您可以創建唱下面的代碼你自己的短代碼。該代碼將返回所有的產品在給定類別
<?php
function view_woocommerce_products($args){
$cat = $args['category'];
$args = array('post_type' => 'product', 'posts_per_page' => -1, 'product_ cat' => $cat);
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post(); global $product; ?>
// Here you can access the product detail by using the $product variable
<?php endwhile; ?>
<?php wp_reset_query();
}
add_shortcode('view-woocommerce-products', 'view_woocommerce_products');
這裏使用簡碼
[view-woocommerce-products category='[your category]']
我試圖做到這一點..但它會取得所有產品然後我需要添加我自己的HTML,但與短代碼HTML是自動寫入 – user3501409
,也是你在哪裏創建簡碼,你只是從數據庫中獲取記錄。 – user3501409
讓我更新代碼 – Mitul
的有短代碼可用於此。結帳這個[鏈接](http://docs.woothemes.com/document/woocommerce-shortcodes/#section-12) –
謝了:) @Rohil_PHPBeginner – user3501409