Home / Forums / WoodMart support forum / Theme Update Product Layout Affected
Home › Forums › WoodMart support forum › Theme Update Product Layout Affected
Theme Update Product Layout Affected
- This topic has 14 replies, 2 voices, and was last updated 1 year, 7 months ago by
Artem Temos.
-
AuthorPosts
-
November 20, 2024 at 8:38 pm #613983
ignitionstudioParticipantI have been leveraging the “extra content” placed “before” on products so that the category title carries over so the user sees consistent page flow… The issue after the latest update to the theme has the content being slightly rearranged. The extra content before is not being placed before the sidebar and so now the sidebar is moved slightly higher and over the content. My ask in support is how do we resolve this because simple css position options are not working. But also, if it would be easier to add the category title to the single product page instead of using the extra content to display an html block is an option, that would be greatly appreciated solution. Then the category titles carry over into the products and I can eliminate the extra content. You can see in my screenshots the current live site has the extra content bar above the main content and sidebar. But following the update to the theme, the other screenshot shows now how the sidebar is over the extra content.
Attachments:
You must be logged in to view attached files.November 21, 2024 at 10:55 am #614135Hello,
Try to remove the extra content and add the following code snippet to the functions.php file in the child theme instead
add_action( 'woodmart_after_header', function () { global $product; if ( ! $product ) { return; } $terms = get_the_terms( $product->get_id(), 'product_cat' ); if ( ! $terms ) { return; } $terms_array = array(); $parent = array(); $child = array(); foreach ( $terms as $term ) { $terms_array[ $term->term_id ] = $term; if ( ! $term->parent ) { $parent[ $term->term_id ] = $term->name; } } foreach ( $terms as $term ) { if ( $term->parent ) { unset( $parent[ $term->parent ] ); if ( array_key_exists( $term->parent, $terms_array ) ) { $child[ $term->parent ] = get_term( $term->parent )->name; } $child[ $term->term_id ] = $term->name; } } $terms = $child + $parent; $title_class = ''; $title_class .= ' title-size-' . woodmart_get_opt( 'page-title-size' ); $title_class .= ' title-design-' . woodmart_get_opt( 'page-title-design' ); $title_class .= ' color-scheme-' . woodmart_get_opt( 'page-title-color' ) ?> <div class="wd-page-title page-title page-title-default <?php echo $title_class; ?>"> <div class="container"> <h1 class="entry-title title"><?php echo array_shift( $terms ); ?></h1> </div> </div> <?php } );Kind Regards
November 21, 2024 at 7:28 pm #614432
ignitionstudioParticipantExcellent. That was the div that I identified as what was missing. However, this fix has now the category title showing twice on the category landing page. See screenshots. Also, I have a script that is replacing category titles with custom brand titles on specific products, so I will attach that script and would love it if you could help me figure out how to apply it to the code you just provided. Thanks much!!!
Attachments:
You must be logged in to view attached files.November 21, 2024 at 7:29 pm #614437
ignitionstudioParticipantcustom script to change woocommerce titles attached…
November 22, 2024 at 10:32 am #614535Try to replace the previous code with the following one
add_action( 'woodmart_after_header', function () { global $product; if ( ! $product || ! is_singular( 'product' ) ) { return; } $terms = get_the_terms( $product->get_id(), 'product_cat' ); if ( ! $terms ) { return; } $terms_array = array(); $parent = array(); $child = array(); foreach ( $terms as $term ) { $terms_array[ $term->term_id ] = $term; if ( ! $term->parent ) { $parent[ $term->term_id ] = $term->name; } } foreach ( $terms as $term ) { if ( $term->parent ) { unset( $parent[ $term->parent ] ); if ( array_key_exists( $term->parent, $terms_array ) ) { $child[ $term->parent ] = get_term( $term->parent )->name; } $child[ $term->term_id ] = $term->name; } } $terms = $child + $parent; $page_title = array_shift( $terms ); $title_class = ''; $title_class .= ' title-size-' . woodmart_get_opt( 'page-title-size' ); $title_class .= ' title-design-' . woodmart_get_opt( 'page-title-design' ); $title_class .= ' color-scheme-' . woodmart_get_opt( 'page-title-color' ); if ( is_product_category('woods-c') ) { $page_title = 'Woods® C'; } if ( is_product_category('backhoes') ) { $page_title = 'Groundbreaker® Backhoes'; } if ( is_product_category('flex-wing-rotary-cutters') ) { $page_title = 'Batwing® Cutters'; } ?> <div class="wd-page-title page-title page-title-default <?php echo $title_class; ?>"> <div class="container"> <h1 class="entry-title title"><?php echo $page_title; ?></h1> </div> </div> <?php } );Kind Regards
November 22, 2024 at 5:30 pm #614790
ignitionstudioParticipantOh man. So close. Thank you, but product-category replacement is not being recognized on the single product still. So this code fixed the duplicate header and when on a category landing page the replacement text appears just fine as before, but on single products it is echoing the default category term and not the custom text. I am not an experienced coder and by looking at your code I cannot see why that wouldn’t happen. I appreciate all the help on this. My agency uses your theme for several clients. Functionality is excellent. This site is perhaps our biggest one leveraging the woocommerce, and would love to keep the client happy with these category adjustments. Let me know if this is possible on the single product pages. Thanks!!!!!
Attachments:
You must be logged in to view attached files.November 25, 2024 at 11:29 am #615427Hello,
Please send us your admin access so we can help you.
Kind Regards
November 25, 2024 at 5:33 pm #615682
ignitionstudioParticipantThank you! login credentials in private content below…
November 25, 2024 at 5:59 pm #615695Here is a new code for this
add_action( 'woodmart_after_header', function () { global $product; if ( ! $product || ! is_singular( 'product' ) ) { return; } $terms = get_the_terms( $product->get_id(), 'product_cat' ); if ( ! $terms ) { return; } $terms_array = array(); $parent = array(); $child = array(); foreach ( $terms as $term ) { $terms_array[ $term->term_id ] = $term; if ( ! $term->parent ) { $parent[ $term->term_id ] = $term->name; } } foreach ( $terms as $term ) { if ( $term->parent ) { unset( $parent[ $term->parent ] ); if ( array_key_exists( $term->parent, $terms_array ) ) { $child[ $term->parent ] = get_term( $term->parent )->name; } $child[ $term->term_id ] = $term->name; } } $terms = $child + $parent; $page_title = array_shift( $terms ); $title_class = ''; $title_class .= ' title-size-' . woodmart_get_opt( 'page-title-size' ); $title_class .= ' title-design-' . woodmart_get_opt( 'page-title-design' ); $title_class .= ' color-scheme-' . woodmart_get_opt( 'page-title-color' ); $terms = get_the_terms(get_the_ID(), 'product_cat'); if ( $terms && !is_wp_error($terms) ) { foreach ( $terms as $term ) { if ( $term->slug === 'woods-c' ) { $page_title = 'Woods® C'; break; } if ( $term->slug === 'backhoes' ) { $page_title = 'Groundbreaker® Backhoes'; break; } if ( $term->slug === 'flex-wing-rotary-cutters' ) { $page_title = 'Batwing® Cutters'; break; } } } ?> <div class="wd-page-title page-title page-title-default <?php echo $title_class; ?>"> <div class="container"> <h1 class="entry-title title"><?php echo $page_title; ?></h1> </div> </div> <?php } );Kind Regards
November 27, 2024 at 12:19 am #616330
ignitionstudioParticipantThank you. I am still not seeing the proper subcategory when on individual products. Your code appears to reference children of parent category but on single products the page title reverts to the parent category and not the subcategory (for example on BrushFighter Cutters it shows Rigid Rotary Cutters and or Disc Harrows it reverts to Tillage). There are a total of 7 categories that have subcategories and while the landing archive works the single products do not.
Attachments:
You must be logged in to view attached files.November 27, 2024 at 11:47 am #616479Hello,
It looks like you changed the admin password and we can’t enter your dashboard now.
Kind Regards
November 27, 2024 at 5:49 pm #616737
ignitionstudioParticipantHello! My mistake. It has been reset to previous access provided…
November 27, 2024 at 6:16 pm #616758Here is the new code for this
add_action( 'woodmart_after_header', function () { global $product; if ( ! $product || ! is_singular( 'product' ) ) { return; } $terms = get_the_terms( $product->get_id(), 'product_cat' ); if ( ! $terms ) { return; } $terms_array = array(); $parent = array(); $child = array(); foreach ( $terms as $term ) { $terms_array[ $term->term_id ] = $term; if ( ! $term->parent ) { $parent[ $term->term_id ] = $term->name; } } foreach ( $terms as $term ) { if ( $term->parent ) { unset( $parent[ $term->parent ] ); if ( array_key_exists( $term->parent, $terms_array ) ) { $child[ $term->parent ] = get_term( $term->parent )->name; } $child[ $term->term_id ] = $term->name; } } $terms = $child + $parent; $page_title = array_pop( $terms ); $title_class = ''; $title_class .= ' title-size-' . woodmart_get_opt( 'page-title-size' ); $title_class .= ' title-design-' . woodmart_get_opt( 'page-title-design' ); $title_class .= ' color-scheme-' . woodmart_get_opt( 'page-title-color' ); $terms = get_the_terms(get_the_ID(), 'product_cat'); if ( $terms && !is_wp_error($terms) ) { foreach ( $terms as $term ) { if ( $term->slug === 'woods-c' ) { $page_title = 'Woods® C'; break; } if ( $term->slug === 'backhoes' ) { $page_title = 'Groundbreaker® Backhoes'; break; } if ( $term->slug === 'flex-wing-rotary-cutters' ) { $page_title = 'Batwing® Cutters'; break; } } } ?> <div class="wd-page-title page-title page-title-default <?php echo $title_class; ?>"> <div class="container"> <h1 class="entry-title title"><?php echo $page_title; ?></h1> </div> </div> <?php } );Kind Regards
November 27, 2024 at 6:33 pm #616771
ignitionstudioParticipantExcellent! Thanks so much for all of your efforts!!!!
November 28, 2024 at 9:50 am #616922You are welcome. Feel free to contact us if you have any further questions.
-
AuthorPosts
The topic ‘Theme Update Product Layout Affected’ is closed to new replies.
- You must be logged in to create new topics. Login / Register