Tagged: Accordion Feature, h3, Toggle Title
-
AuthorPosts
-
March 26, 2024 at 8:00 pm #1438368
Is it possible to make the Toggle Titles in the accordion feature H3’s without breaking the functionality? I don’t need to change the formatting or size of the text, but need them to be H3’s for SEO purposes. Thanks.
March 27, 2024 at 12:29 am #1438384put this to your child-theme functions.php:
function my_avf_customize_heading_settings( array $args, $context, array $extra_args = array() ){ if( $context == 'avia_sc_toggle' ){ $args['heading'] = 'h3'; } return $args; } add_filter( 'avf_customize_heading_settings', 'my_avf_customize_heading_settings', 10, 3 );
March 27, 2024 at 7:16 am #1438401Hi,
Thank you for the inquiry.
Aside from using the filter above, you can also adjust the Advanced > Toggle Titles > Toggle Title Tag settings.
Best regards,
Ismael2March 27, 2024 at 8:18 am #1438414By the way Ismael, would it be possible to change the filter conditionally like in the Alb Element itself?
Because my method above changes all toggle titles at once, but has the disadvantage that if an individual tag has been set, this is also subject to the filter.The alb itself got this ternary operator
$default_heading = ! empty( $meta['heading_tag'] ) ? $meta['heading_tag'] : 'p';
so is it possible to use the filter – but leave it untouched if meta heading_tag is set?
March 27, 2024 at 11:03 am #1438424Hi,
@Guenni007: You could check the value of the heading within the $args variable. If it’s set to the default value (p), proceed; otherwise, use the selected heading_tag.Best regards,
IsmaelMarch 27, 2024 at 1:11 pm #1438442Thanks for the quick replies and info Ismael and Guenni007.
Changing the option under the Advanced > Toggle Titles > Toggle Title Tag settings worked perfectly.
March 27, 2024 at 7:49 pm #1438478Hi NicomIT,
Thanks for the update. Please let us know if you should need any further help on the topic, or if we can close it.
Best regards,
RikardMarch 28, 2024 at 7:58 am #1438519@Ismael : Please show a working snippet. – I have tried many things with no result.
March 28, 2024 at 8:19 am #1438524Hi,
@Guenni007: Please try this filter:function my_avf_customize_heading_settings(array $args, $context, array $extra_args = array()) { if ($context == 'avia_sc_toggle' && $args['heading'] === 'p') { $args['heading'] = 'h3'; } return $args; } add_filter('avf_customize_heading_settings', 'my_avf_customize_heading_settings', 10, 3);
We just added this condition:
&& $args['heading'] === 'p'
Best regards,
IsmaelMarch 28, 2024 at 1:05 pm #1438544yes thanks that works – do we have to use strict equality here?
A small drawback: if you want to set the p-tag in the Alb, this is no longer possible.March 28, 2024 at 5:51 pm #1438557Hi @Guenni007,
strict equality
No, not needed.
p-tag
You need to check $extra_args. In the ALB element you find:
$extra_args = array( $this, $atts, $content, 'title' );
means you can use:
$atts = extra_args [1];
and you have access to all shortcode attributes – if you set a custom id or class you can check it here.
Best regards,
Günter- This reply was modified 8 months, 3 weeks ago by Günter.
March 28, 2024 at 6:17 pm #1438560Please tell me how –
i know that i can have a child-theme toggles.php – but it might be possible to only replace the heading_tag by that filter if choice is on “Theme default”April 1, 2024 at 10:37 am #1438883Hi @Guenni007,
Sorry for the late reply.
function my_avf_customize_heading_settings(array $args, $context, array $extra_args = array()) { if( $context != 'avia_sc_toggle' ) { return $args; } $atts = $extra_args [1]; if( '' == $atts['heading_tag'] ) { $args['heading'] = 'h3'; } return $args; } add_filter('avf_customize_heading_settings', 'my_avf_customize_heading_settings', 10, 3);
$atts['heading_tag']
is the value of the selectbox “Toggle Title Tag (Theme Default is <p>)”
Best regards,
GünterApril 2, 2024 at 10:39 am #1438974I would never have thought of it myself. Thank you so much.
But I don’t quite understand the logic. Because I want to change this just for the toggles only (so why the not equal) – wouldn’t a logical combination of both conditions be the method of choice?
function my_avf_customize_heading_settings(array $args, $context, array $extra_args = array()){ $atts = $extra_args [1]; if( $context == 'avia_sc_toggle' && $atts['heading_tag'] == ''){ $args['heading'] = 'h3'; } return $args; } add_filter('avf_customize_heading_settings', 'my_avf_customize_heading_settings', 10, 3);
April 2, 2024 at 11:04 am #1438976Hi @Guenni007,
In my solution I leave the filter right away if not ‘avia_sc_toggle’ avoiding copying of $extra_args [1] if not needed (arrays are copied and not only a reference to it).
Your solution is also OK. Depending on what you want to do or what other logic you need in this filter (e.g. for other elements) there are always different approaches.
Best regards,
GünterApril 2, 2024 at 11:30 am #1438979ok – now I understand the negation – if it is not the toggle, the filter is left. I’ve learnt something new.
_______
for : avia_sc_contact , avia_sc_icon_box , avia_sc_iconlist
it will work too.
for the last one i do not know how to differ between small list and big list if needed.but for avia_sc_content_slider and avia_sc_partner_logo – it does not work that way
PS: ok i see – for partner logo it is : avia_partner_logo – and for content slider it is: avia_content_slider
(wrong if ( ! class_exists statement )now with contentslider i got those extra_args : slider_title and slider_entry
how to combine it in this case?i know how to include that extra_args on f.e. timeline:
if( $context == 'avia_sc_timeline' && is_array( $extra_args ) && in_array( 'title', $extra_args ) )
but the combination is hard for me to see how to obtain that.
April 2, 2024 at 12:27 pm #1438983Hi,
avia_sc_iconlist
correct – currently not possible. I will add the attributes of “container” element to $extra_args. Will let you know here.
avia_sc_content_slider
it is avia_content_slider
Best regards,
GünterApril 2, 2024 at 12:52 pm #1438987Hi @Guenni007,
see line 1117 ff
In filter use:
$element_atts = $extra_args[4];
and for styling:
$element_atts['iconlist_styling'] // '' | 'av-iconlist-small'
Best regards,
GünterApril 2, 2024 at 12:53 pm #1438988PS: ok i see – for partner logo it is : avia_partner_logo – and for content slider it is: avia_content_slider
ok – and i edited that post for content_slider – how to differ with slider_title and slider_entry ?
thats not possible for now?April 2, 2024 at 1:11 pm #1438992Hi,
$extra_args[1] = ‘slider_title’ | ‘slider_entry’
see lines 1096, 1182 ff
Best regards,
GünterApril 2, 2024 at 8:00 pm #1439023Hey there. Quick update on what I implemented.
Things worked good. Just one issue – when viewed on a mobile device, the accordion titles don’t always open when clicked on. Sometimes they work fine, but then other times nothing happens when you click on them. Here are two pages where the accordion has been set-up and we are seeing this issue:
https://www.nicomit.com/
https://www.nicomit.com/services/managed-technical-support-services/Any help would be appreciated. Thanks!
April 5, 2024 at 7:15 am #1439248Hi,
Looks like the issue also happens on desktop view. It might be due the following script error which is generated from the compressed (autoptimize_single) script.
Uncaught TypeError: $.avia_utilities.supports is not a function at avia_hover_effect (autoptimize_single_aec3c90c3ca8780bf5fccbd8621958ec.js:105:42) at $.avia_utilities.avia_ajax_call (autoptimize_single_aec3c90c3ca8780bf5fccbd8621958ec.js:33:29) at HTMLDocument.<anonymous> (autoptimize_single_aec3c90c3ca8780bf5fccbd8621958ec.js:11:44) at e (jquery.min.js:2:27028) at t (jquery.min.js:2:27330)
Please try to deactivate the Autoptimize plugin temporarily and let us know of the result.
Best regards,
IsmaelApril 5, 2024 at 2:04 pm #1439286Hi Ismael,
Thanks for having a look at that. I think it was related to the Autoptimize plugin. I disabled that and the accordions look to be working. Can you check on your end?They were working in Chrome on desktop, but when I checked in Edge they were having the same issue that we were seeing on mobile. They are working in Edge now that the plugin has been disabled.
Ryan
April 6, 2024 at 2:24 pm #1439321One question about sliders – the context is on all sliders : avia_slideshow
and filter is placed inside class-avia-slideshow.php – the $default_heading is build differently to the other alb elements.how to only replace the default setting (h2) only e.g. for easy-slider (avia_sc_slider)?
April 8, 2024 at 3:48 am #1439458Hi,
@NicomIT: Yes, the toggles are now working as expected. Please feel free to open another thread if you have more questions.
@Guenni007: Looks like the filter avf_customize_heading_settings is not available for the avia_sc_slider class. We’ll forward this to our channel.Best regards,
IsmaelApril 8, 2024 at 9:37 am #1439470yes it is all inside the helper file: class-avia-slideshow
but even if i use that class: avia_slideshow the extra_args [1] will not work herebtw: I think it would generally make more sense if the filter could only ever replace the “default setting”. After all, if you have manually set a different heading tag, you usually want to keep it. Or do you not?
April 8, 2024 at 3:51 pm #1439503Hi @Guenni007,
I modified the filter parameters (see line 973ff).
You can use this filter now like:
function my_avf_customize_heading_settings( array $args, $context, array $extra_args = array() ) { if( 'avia_slideshow' == $context ) { // get class of slideshow $slider_class = get_class( $extra_args[2] ); if( in_array( $slider_class, [ 'avia_sc_slider', 'avia_sc_slider_fullscreen', 'avia_sc_slider_full' ] ) ) { $index = $extra_args [1]; // current slide in loop $slide = $extra_args [3]; // get shortcode attributes of current slide $attr = $slide['attr']; // only change for first slide and when default if( '' == $attr['heading_tag'] && 0 == $index ) { $args['heading'] = 'h3'; } } } return $args; } add_filter( 'avf_customize_heading_settings', 'my_avf_customize_heading_settings', 10, 3 );
… only ever replace the “default setting” ….
It gives more flexibility e.g. if there is dynamic created content on the page (e.g. like in upcoming 6.0 with ACF fields and/or in custom layouts )
Best regards,
GünterApril 8, 2024 at 4:45 pm #1439510Many thanks !!!
So if I want to disregard the slide number – and just want to change all default headings in the Easy-Slider to h1 – then:
i do not need the index in this casefunction my_avf_customize_heading_settings( array $args, $context, array $extra_args = array()){ if( 'avia_slideshow' == $context ){ // get class of slideshow $slider_class = get_class( $extra_args[2] ); if( in_array( $slider_class, [ 'avia_sc_slider' ])){ // current slide in loop $slide = $extra_args [3]; // get shortcode attributes of current slide $attr = $slide['attr']; // only change for first slide and when default if( '' == $attr['heading_tag'] ){ $args['heading'] = 'h1'; } } } return $args; } add_filter( 'avf_customize_heading_settings', 'my_avf_customize_heading_settings', 10, 3 );
April 9, 2024 at 12:39 pm #1439578April 9, 2024 at 9:17 pm #1439612From my point of view the topic can be closed now – thanks again.
-
AuthorPosts
- The topic ‘Change Toggle Title in Accordion Feature to H3’ is closed to new replies.