Community Forums › Forums › Archived Forums › Design Tips and Tricks › Woocommcerce thumbnal in Genesis Archive Description
Tagged: Archive Description, category image, WooCommerce
- This topic has 6 replies, 2 voices, and was last updated 8 years, 7 months ago by Peaceless.
-
AuthorPosts
-
August 29, 2015 at 4:20 am #163981PeacelessMember
Hi!
I´m trying to figure out how to make the thumbnail you can upload to a product category in Woocommerce, to show up next to the Archive description. I figured since I can make this work for the "usual" description using the below code it would be better to use the same logic to pull it in the thumbnail rather than using HTML in the Archive description section, do you agree? Or is it pretty much the same? This is the code that I used for having the image show up in the "usual" description
add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 ); function woocommerce_category_image() { if ( is_product_category() ){ global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); if ( $image ) { echo '<img src="' . $image . '" alt="" />'; } } }
Figure I should replace the 'woocommerce_archive_description' with something and tried to see this with the Visual hooks guide but I´m still lost. Am I on the right track? Or you think I should go with the HTML solution?
August 29, 2015 at 5:31 am #163985Brad DaltonParticipantYou can copy over the archive-product.php from the genesis connect woo commerce plugin and add code to that file.
<?php /** Remove default Genesis loop */ remove_action( 'genesis_loop', 'genesis_do_loop' ); /** Remove WooCommerce breadcrumbs */ remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 ); /** Uncomment the below line of code to add back WooCommerce breadcrumbs */ //add_action( 'genesis_before_loop', 'woocommerce_breadcrumb', 10, 0 ); /** Remove Woo #container and #content divs */ remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); /** Get Shop Page ID */ // @TODO Retained for backwards compatibility with < 1.6.0 WooC installs global $shop_page_id; $shop_page_id = get_option( 'woocommerce_shop_page_id' ); add_filter( 'genesis_pre_get_option_site_layout', 'genesiswooc_archive_layout' ); function genesiswooc_archive_layout( $layout ) { global $shop_page_id; $layout = get_post_meta( $shop_page_id, '_genesis_layout', true ); return $layout; } add_action( 'genesis_before_loop', 'genesiswooc_archive_product_loop' ); function genesiswooc_archive_product_loop() { global $woocommerce; $new = version_compare( $woocommerce->version, '1.6.0', '>=' ); if ( $new ) genesiswooc_content_product(); else genesiswooc_product_archive(); } genesis();
September 4, 2015 at 10:03 am #164583PeacelessMemberhey!
thanks but that made both the Archive Head line and archive intro text to disappear all together 🙂
September 5, 2015 at 2:49 am #164646Brad DaltonParticipantAnd then add code to that file to add whatever you like including the archive info.
Did you add your code to the file?
September 5, 2015 at 9:51 am #164665PeacelessMemberI took a shot and added the code I posted above to the functions.php to see if that was what you ment but it just got me the thumbnal in the ordinary description. So I guess I don´t follow you... 🙂
Am I off target if I assume that 'woocommerce_archive_description' in the code I posted above is the "normal" archive description and I should replace that with whatever the Archive description, that genesis put in the archive settings page for a product, is called?
September 5, 2015 at 10:05 am #164667PeacelessMemberHmm, now the description with the image using HTML has disappeared ....even if I delete the archive-product.php I copied over...strange
September 6, 2015 at 9:51 am #164744PeacelessMemberah, it´s bug! doh!
geeez
ok so I´m back at the thing with adding the thumbnail...
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.