-
AuthorPosts
-
August 28, 2014 at 8:42 am #310296
Hi,
I am trying to customize the product page as if it were a normal page. I already read that is not possible to use Layout Builder. So I created the shortcode in a normal page edit and then pasted it in the product content edit page ( I know how to move the content from the TAB Description to where I want in the template ). Anyway I see it doesn’t work, because I saw in the source page that a lot of stuff is missing. Is it right? Is there a way to use the shortcode for a slider or similar and make it works inside the product template?If it is not, I am trying a new way.
I create a normal page for the product and then from the shop I change the url that point to that page ( from product page to my custom page for the product ). The link are two: one on the thumbnail, the other in show details.
I made a custom filed for my custom page where I can choose the product ID from a list of all products. In this way the page and the product are connected.
For Show Details link there’s no problem.
But for the thumbnail I see in config.php that you remove and add action. The active code is this:function avia_woocommerce_thumbnail($asdf) { global $product, $avia_config; $rating = $product->get_rating_html(); //get rating $id = get_the_ID(); $size = 'shop_catalog'; echo "<div class='thumbnail_container'>"; echo avia_woocommerce_gallery_first_thumbnail( $id , $size); echo get_the_post_thumbnail( $id , $size ); if(!empty($rating)) echo "<span class='rating_container'>".$rating."</span>"; if($product->product_type == 'simple') echo "<span class='cart-loading'></span>"; echo "</div>"; }
But I see in the html that the tag a is outside the <div class=’thumbnail_container’>, and I really don’t find where it is generated.
Thanks for support!
- This topic was modified 10 years, 3 months ago by Gurify.
August 29, 2014 at 12:01 pm #310864Hi Gurify!
Yes, Kriesi uses a hook to change the html structure of the products a bit. With
add_action( 'woocommerce_before_shop_loop_item', 'avia_shop_overview_extra_div', 5);
Enfold adds an extra div between the li element and the product link (a element) of the default product loop – see default template here: https://github.com/woothemes/woocommerce/blob/master/templates/content-product.php which outputs the link with:
<li <?php post_class( $classes ); ?>> <?php do_action( 'woocommerce_before_shop_loop_item' ); ?> <a href="<?php the_permalink(); ?>"> <?php /** * woocommerce_before_shop_loop_item_title hook * * @hooked woocommerce_show_product_loop_sale_flash - 10 * @hooked woocommerce_template_loop_product_thumbnail - 10 */ do_action( 'woocommerce_before_shop_loop_item_title' ); ?> <h3><?php the_title(); ?></h3> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_rating - 5 * @hooked woocommerce_template_loop_price - 10 */ do_action( 'woocommerce_after_shop_loop_item_title' ); ?> </a> <?php do_action( 'woocommerce_after_shop_loop_item' ); ?> </li>
The “woocommerce_before_shop_loop_item_title” hook is used to add the featured thumbnail and the buttons to the product loop (see code you posted in your post).
Is there a way to use the shortcode for a slider or similar and make it works inside the product template?
Yes, if you rewrite the code. However it’s not easy and probably requires some hours of work because you need to find a way to set the slideshow images, etc. Basically you need to replace the featured image function with do_shortcode(): http://codex.wordpress.org/Function_Reference/do_shortcode to execute the slideshow shortcode – i.e. replace:echo get_the_post_thumbnail( $id , $size );
with
echo do_shortcode( '[YOUR SORTCODE]' );
and replace [YOUR SORTCODE] with the slideshow shortcode. The hard part is to generate the slideshow shortcode/content dynamically for each post.
Best regards,
Peter -
AuthorPosts
- You must be logged in to reply to this topic.