Home › Forums › WoodMart support forum › Accordion Title
Accordion Title
- This topic has 1 reply, 2 voices, and was last updated 3 weeks, 4 days ago by
Hung Pham.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
April 7, 2025 at 4:28 pm #652234
piotrburchartParticipantHi.
Is it possible to change Accordion Title from <span> to H3 tag?
Thank you
April 8, 2025 at 7:54 am #652357
Hung PhamKeymasterHello piotrburchart,
Thanks for reaching to us.
1. Try to replace the code in the functions.php file of the child theme:
// Hook into Elementor to register the custom widget add_action( 'elementor/widgets/register', function( $widgets_manager ) { // Define the custom widget class by extending the parent class class Woodmart_Accordion_Child extends XTS\Elementor\Accordion { /** * Override the render method to replace <span> with <h2> for the item title. */ protected function render() { $default_settings = array( /** * General Settings. */ 'style' => 'default', 'state' => 'first', 'hide_top_bottom_border' => '', /** * Title Settings. */ 'title_text_alignment' => 'left', /** * Content Settings. */ 'content_text_color_scheme' => 'inherit', /** * Icon Settings. */ 'opener_alignment' => 'left', 'opener_style' => 'arrow', ); $settings = wp_parse_args( $this->get_settings_for_display(), $default_settings ); woodmart_enqueue_js_script( 'accordion-element' ); woodmart_enqueue_inline_style( 'accordion' ); woodmart_enqueue_inline_style( 'accordion-elem-wpb' ); $wrapper_classes = ' wd-style-' . $settings['style']; if ( 'yes' === $settings['hide_top_bottom_border'] ) { $wrapper_classes .= ' wd-border-off'; } $wrapper_classes .= ' wd-titles-' . $settings['title_text_alignment']; $wrapper_classes .= ' wd-opener-pos-' . $settings['opener_alignment']; $title_classes = ''; if ( 'inherit' !== $settings['title_text_color_scheme'] && 'custom' !== $settings['title_text_color_scheme'] ) { $title_classes .= ' color-scheme-' . $settings['title_text_color_scheme']; } $wrapper_classes .= ' wd-opener-style-' . $settings['opener_style']; $content_classes = ''; if ( 'inherit' !== $settings['content_text_color_scheme'] && 'custom' !== $settings['content_text_color_scheme'] ) { $content_classes .= ' color-scheme-' . $settings['content_text_color_scheme']; } ?> <div class="wd-accordion<?php echo esc_attr( $wrapper_classes ); ?>" data-state="<?php echo esc_attr( $settings['state'] ); ?>"> <?php foreach ( $settings['items'] as $index => $item ) : ?> <?php $content_setting_key = $this->get_repeater_setting_key( 'item_content', 'items', $index ); $this->add_inline_editing_attributes( $content_setting_key ); $loop_title_classes_wrapper = ''; $loop_content_classes_wrapper = ''; if ( 0 === $index && 'first' === $settings['state'] ) { $loop_title_classes_wrapper .= ' wd-active'; $loop_content_classes_wrapper .= ' wd-active'; } $loop_content_classes_wrapper .= $content_classes; // Icon settings. $image_size = array( 'width' => 128, 'height' => 128, ); if ( isset( $item['image_size'] ) && ! empty( $item['image_size'] ) && 'custom' !== $item['image_size'] ) { $image_size = $item['image_size']; } elseif ( 'custom' === $item['image_size'] && isset( $item['image_custom_dimension']['width'] ) && ! empty( $item['image_custom_dimension']['width'] ) ) { $image_size = $item['image_custom_dimension']; } $icon_output = ''; if ( 'image' === $item['icon_type'] && isset( $item['image']['id'] ) && $item['image']['id'] ) { $icon_output = woodmart_otf_get_image_html( $item['image']['id'], $item['image_size'], $item['image_custom_dimension'] ); if ( woodmart_is_svg( $item['image']['url'] ) ) { $icon_output = woodmart_get_svg_html( $item['image']['id'], $image_size ); } } elseif ( 'icon' === $item['icon_type'] && $item['icon'] ) { $icon_output = woodmart_elementor_get_render_icon( $item['icon'] ); } ?> <div class="wd-accordion-item"> <div class="wd-accordion-title<?php echo esc_attr( $loop_title_classes_wrapper ); ?>" data-accordion-index="<?php echo esc_attr( $index ); ?>"> <div class="wd-accordion-title-text<?php echo esc_attr( $title_classes ); ?>"> <?php if ( ! empty( $icon_output ) ) : ?> <span class="img-wrapper"> <?php echo $icon_output; // phpcs:ignore ?> </span> <?php endif; ?> <!-- Replace <span> with <h2> --> <h2> <?php echo esc_html( $item['item_title'] ); ?> </h2> </div> <span class="wd-accordion-opener"></span> </div> <div class="wd-accordion-content wd-entry-content<?php echo esc_attr( $loop_content_classes_wrapper ); ?>" data-accordion-index="<?php echo esc_attr( $index ); ?>"> <?php if ( 'html_block' === $item['content_type'] ) : ?> <?php echo woodmart_get_html_block( $item['html_block_id'] ); // phpcs:ignore ?> <?php elseif ( 'text' === $item['content_type'] ) : ?> <?php if ( woodmart_elementor_is_edit_mode() ) : ?> <div <?php echo $this->get_render_attribute_string( $content_setting_key ); ?>> <?php endif; ?> <?php echo do_shortcode( $item['item_content'] ); ?> <?php if ( woodmart_elementor_is_edit_mode() ) : ?> </div> <?php endif; ?> <?php endif; ?> </div> </div> <?php endforeach; ?> </div> <?php } } // Unregister the parent widget $widgets_manager->unregister( 'wd_accordion' ); // Register the child widget $widgets_manager->register( new Woodmart_Accordion_Child() ); }, 20 ); // Priority 20 to ensure it runs after the parent widget is registered
2. Please add the below Custom CSS code to Theme Settings > Custom CSS > Global Custom CSS:
.wd-accordion-title-text h2{ margin-bottom: 0; }
Kind Regards
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to create new topics. Login / Register