Y
Y
Yuri Avanesov2018-04-04 14:25:09
WordPress
Yuri Avanesov, 2018-04-04 14:25:09

How to set a template for displaying products on the main WooCommerce?

Hello!
I want to display new and popular products on the main page. To do this, you can use shortcodes, you can use special functions. For example, the new release function:

if ( ! function_exists( 'storefront_recent_products' ) ) {
/**
* Display Recent Products
* Hooked into the `homepage` action in the homepage template
*
* @since 1.0.0
* @param array $args the product section args.
* return void
*/
function storefront_recent_products( $args ) {
if ( storefront_is_woocommerce_activated() ) {
$args = apply_filters( 'storefront_recent_products_args', array(
'limit' => 12,
'columns' => 4,
'title' => __ ( 'New In', 'storefront' ),
) );
$shortcode_content = storefront_do_shortcode( 'recent_products', apply_filters( 'storefront_recent_products_shortcode_args', array(
'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ),
) ) );
/**
* Only display the section if the shortcode returns products
*/
if ( false !== strpos( $shortcode_content, 'product' ) ) {
echo '';
do_action( 'storefront_homepage_before_recent_products' );
echo '' . wp_kses_post( $args['title'] ) . '';
do_action( 'storefront_homepage_after_recent_products_title' );
echo $shortcode_content;
echo '';
}
}
}
}

But he takes the structure of goods from the category. I need the structure of products in the category and on the main page to be different (different html structure, number of output elements for the product). How can I do that? How is this indicated in the function?
I will be grateful for your help!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question