Stop Elementor's Accordion Opening on the 1st Tab

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 มิ.ย. 2021
  • This is a common issue where the Accordion in Elementor always opens on the 1st Tab. It can be annoying when you don't want that or you have multiple accordion's on the same page.
    Use this code in the Custom CSS (of the Advanced Tab of the Accordion) to prevent it. Note that you need to have a fake tab as the very first one.
    The Code is below in the Comments.
    PS: websquadron.co.uk
    PPS: Don't miss out on our amazing Create a Website in One Weekend Course - and it comes with a FREE Elementor Pro License!! websquadron.co.uk/createwebsi...
    PPPS: Contact us for any questions or to collaborate.
    PPPPS: I must stress that we only build with Elementor and no other Page Builder.
  • แนวปฏิบัติและการใช้ชีวิต

ความคิดเห็น • 128

  • @websquadron
    @websquadron  2 ปีที่แล้ว +10

    Make sure that you put 'accord' in the CSS Class Name.
    .accord .elementor-accordion > div:first-of-type { display:none;}
    /*The bit below adds the top border back in*/
    .accord .elementor-accordion {
    border-top-style: solid;
    border-top-width: 1px;
    border-top-color: #ff0000;
    }

    • @markimarku
      @markimarku 8 หลายเดือนก่อน +1

      "Make sure that you put 'accord' in the CSS Class Name."
      Is that class ID or is it CSS classes (in the advanced tab)?

  • @websquadron
    @websquadron  3 ปีที่แล้ว +11

    Here's the CSS that you'll need:
    .elementor-accordion > div:first-of-type { display:none;}

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      @Blue Room IT Not that I am aware of, but I'll check for any 'n' variable that allows that.

    • @dannysparrow
      @dannysparrow 2 ปีที่แล้ว +1

      Thank you!

  • @andyk8840
    @andyk8840 ปีที่แล้ว +1

    OMG. I thought I was the only one having this issue! You are a lifesaver my friend. Thank you!!!!!

  • @miaobergs
    @miaobergs ปีที่แล้ว +1

    Wow, it seams that whatever I need for customizing Elementor you have a great solution for that. Thanks again Web Squadron for being so helpful

  • @zackattack7103
    @zackattack7103 ปีที่แล้ว +1

    I just recently built 3 pages with this exact issue. Great fix.....thanks alot. It was a real problem. Ill execute this in the morning.

  • @b.mcguiredesigns
    @b.mcguiredesigns 3 ปีที่แล้ว +2

    Dead simple! Thank you for this great workaround. This is now in my list of "Super Awesome Code Snippets!"

    • @websquadron
      @websquadron  3 ปีที่แล้ว

      I'd love to see your entire list of Super Awesome Code Snippets! Please do share: info@websquaron.co.uk :)

  • @ryanclimer
    @ryanclimer 3 ปีที่แล้ว +1

    Just used this on my site. Worked like a charm. Thank you!

  • @JillyCrystal
    @JillyCrystal 2 ปีที่แล้ว +2

    Thanks for your tutorial! I was trying the javascript approach shown in other tutorials but it didn't work. Yours works like a charm! Keep up with your great work :) Liked and subscribed

  • @filmo110
    @filmo110 2 ปีที่แล้ว +1

    Brilliant this solution to an already very old problem!
    Just a little more information:
    in case of responsive design (computer, tablet and mobile) with duplication of the accordion widget and use of the advanced "Responsive" function, the pseudo-element (to be hidden) of the first accordion must be present for each of the designs otherwise you will hide the first useful element for the screen where there is none.
    CSS code, on the other hand, can be implemented in one place.

  • @jcoreboi5017
    @jcoreboi5017 2 ปีที่แล้ว +1

    a simple and practical solution 😎THX bro

  • @philwatson8694
    @philwatson8694 7 วันที่ผ่านมา

    Thanks so much Imran another life saver

  • @_mzkr_
    @_mzkr_ 2 ปีที่แล้ว +2

    Thanks for pointing out the solution. It's strange that they have not corrected this yet. It has been literally years. I'd also add as a possible option that the presented code could have the Elementor 'selector' at the start so it only applies it to that accordion instance otherwise the code will apply to every accordion sitewide. Oh and I did a different type of child element call.
    selector .elementor-accordion-item:first-of-type {
    display: none;
    }
    Thanks again 👍

  • @amiebrown7594
    @amiebrown7594 ปีที่แล้ว

    Thank you so much! This is a great tutorial.

  • @stevechong65
    @stevechong65 2 ปีที่แล้ว +1

    Thanks Imran, save me tons of time!

  • @promiseeffiong7868
    @promiseeffiong7868 2 ปีที่แล้ว +1

    Thank you for this.

  • @pixelgap
    @pixelgap 2 ปีที่แล้ว +1

    I found tons of videos online with similar solution but nothing worked. This actually worked like a charm. Thank you Imran. I don't understand why Elementor does not add this option to the widget.

  • @mattesaena7202
    @mattesaena7202 5 หลายเดือนก่อน

    A big thank you for posting this helpful video!

  • @pointier4193
    @pointier4193 ปีที่แล้ว

    This is beyond helpful thank you for the tutorial! Although I did have a question; If I was to change the Title HTML Tag on the accordion to a h2, it looks like even the "fake" tab is able to be seen by SEO tools (I'm using SEO minion Chrome extension to check on page) do you know of a way to combat this?

  • @SantiagodelosSantos
    @SantiagodelosSantos 2 ปีที่แล้ว +1

    Awesome solution

  • @markimarku
    @markimarku 8 หลายเดือนก่อน

    that is so genius. Thank you

  • @MrAbseil1
    @MrAbseil1 ปีที่แล้ว +1

    this was such a bloody annoying feature of this widget. you r a legend dude!

    • @websquadron
      @websquadron  ปีที่แล้ว

      I hope they make it a default setting on the accordion in the future.

  • @Leo-vj6df
    @Leo-vj6df ปีที่แล้ว

    Thank you bro, you are a lifesaver

  • @janisaarinen7443
    @janisaarinen7443 2 ปีที่แล้ว +1

    thank you so much

  • @romano5785
    @romano5785 2 ปีที่แล้ว +1

    Finally one that actually works!

  • @meshachkoech2979
    @meshachkoech2979 ปีที่แล้ว

    Thank you

  • @MH-uc4ip
    @MH-uc4ip 2 ปีที่แล้ว +1

    Wauw thank you so much!

  • @udoyhalderakash7206
    @udoyhalderakash7206 2 ปีที่แล้ว +1

    Wow, nice HelpFull ❣️❣️

  • @frajack
    @frajack ปีที่แล้ว

    thank youuuu! super useful!! 🤩

  • @healthyhealthtipswithafifa3051
    @healthyhealthtipswithafifa3051 2 ปีที่แล้ว +1

    Thank you so much my issue is sortout. Can you please share me perfect small size booking form plugin with country list as I need to add short code in accordion section. As customers open accordion they will get Booking form

  • @kookito
    @kookito 2 ปีที่แล้ว +1

    very clever mate!

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      Makes a big difference right :)

  • @marieclaire911
    @marieclaire911 ปีที่แล้ว

    you legend, thank you

  • @BizTechMastery
    @BizTechMastery ปีที่แล้ว +1

    Thanks :)

  • @stevechong65
    @stevechong65 2 ปีที่แล้ว +1

    But I have a problem now. A client maintained a blog type of narrations for the past 12 years. I have created all 12 years of the records and put them in template, then I called them using the Accordion method as shown. But it took more than 30s sometimes even up to a minute plus to load the page. Accordion was loading the data in the templates apparently, so than when the title is click, the data will be displayed instantaneously.
    The "blog" type of narrations consists of one or more images, below 150k each and the narrations are below 250 words.
    I wonder if there are any better ways to handle the case. I was hoping the timeline could be displayed on the same page but with faster preloading time.
    As always, appreciate your help.

    • @websquadron
      @websquadron  2 ปีที่แล้ว +2

      I know what you mean about too much content slowing things down. Are the images Webp to make them smaller? Would be better to just use Posts and have a Post Filter.

    • @stevechong65
      @stevechong65 2 ปีที่แล้ว

      @@websquadron thanks for the reply. I would say the images were pretty well compressed, less than 150KB, good enough to strike a balance btw. quality and file size. There were 12 years of narrations, average about 1-2 posts a month, that would be like almost 300 posts. Using HTML, he was able to put all of them in just 1 page and it loads well. (he took down the site though).
      The thing is when migrating to WP, he still wants to load all of them in one page, and
      Client is reluctant to use "another" plugin just for a single page/job. * sigh

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      @@stevechong65 Are the images WebP?

    • @stevechong65
      @stevechong65 2 ปีที่แล้ว

      @@websquadron they are jpegs

    • @stevechong65
      @stevechong65 2 ปีที่แล้ว

      @@websquadron I may have found the solution, instead of using Accordion, I would use links and call the popups respectively, that way I could still keep the user on the same page. However, the scroll effects might not work, *sigh

  • @romandasaleknavicius2677
    @romandasaleknavicius2677 ปีที่แล้ว +1

    How to make opened by default specific tab? F.e. the second one?

    • @websquadron
      @websquadron  ปีที่แล้ว +2

      I would rearrange them to be honest and make Number 2 be Number 1

  • @hoopstalkcentral
    @hoopstalkcentral 3 ปีที่แล้ว +1

    we can do this with javascript without using your css right?

    • @websquadron
      @websquadron  3 ปีที่แล้ว +1

      Indeed, yes you can.
      If you insert some HTML Code - this would do it.
      jQuery(document).ready(function($) {
      var delay = 100; setTimeout(function() {
      $('.elementor-tab-title').removeClass('elementor-active');
      $('.elementor-tab-content').css('display', 'none'); }, delay);
      });
      PS - I'm not a massive HTML/CSS Coder.
      PPS - SQL Programming on the other-hand - I consider myself a powerhouse (but that's a different story)
      PPPS - I find many prefer simpler codes like the CSS one above but all answers are good.
      PPPPS - Thanks for reminding me to put the Javascript in
      PPPPPS - do paste in any other codes or methods that you think are useful for people - because it's all good.
      Take care :)

  • @Llaneromar
    @Llaneromar ปีที่แล้ว +1

    Genio!

  • @BasitAli-my1tp
    @BasitAli-my1tp 2 ปีที่แล้ว +1

    Thanku so much

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      Any time

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      This will help you more: th-cam.com/video/ycnDfUG1ZbI/w-d-xo.html

  • @nickverduyn7723
    @nickverduyn7723 4 หลายเดือนก่อน

    It's not working. I added the CSS Class Name and the code in the Advanced section where it says "Custom CSS" but the first is still showing and opening.

    • @websquadron
      @websquadron  4 หลายเดือนก่อน

      Use the new accordion widget that prevents this now

  • @techdelasabana
    @techdelasabana 3 ปีที่แล้ว +1

    If an accordion with this css code is interpreted by Google's search engine as a FAQ Schema, does the fake element appear in the search results as well?

    • @websquadron
      @websquadron  3 ปีที่แล้ว +1

      Only if you set that FAQ to be marked up as FAQ Schema.
      rankmath.com/kb/faq-schema-elementor/

    • @websquadron
      @websquadron  3 ปีที่แล้ว +1

      And I would apply caution. There are other solutions that you could also use to keep the first tab closed. Go with what you're most comfortable with.

    • @websquadron
      @websquadron  3 ปีที่แล้ว +2

      What I will also add - is that you could add a reasonable Query in Tab 1 - which isn't vital to be shown, but if Google makes it visible on their search results, then it's fine too.
      Eg: The First Tab could be "Are these FAQ Updated Regularly?"
      Answer: "We update and share the most frequent questions and review on an ongoing basis".
      Etc. Job done.

    • @techdelasabana
      @techdelasabana 3 ปีที่แล้ว +1

      @@websquadron Great idea! Sounds better

    • @websquadron
      @websquadron  3 ปีที่แล้ว

      @@techdelasabana Ace :)

  • @one9seven675
    @one9seven675 2 ปีที่แล้ว +1

    Problem is that you lose the top border of the accordion if you hide the first block. Any fix to that?

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      Interesting as I don't get that problem.
      Have you a URL to share?

    • @one9seven675
      @one9seven675 2 ปีที่แล้ว

      @@websquadron you are getting it on your video - if you notice the accordion is missing the top border line on the "2nd" item when you hide the first. You can see exactly the problem in your video. :) If you go to 6:09 in the video and look at your top accordion you will see that the top border line on your now first item is missing the line.

    • @websquadron
      @websquadron  2 ปีที่แล้ว +2

      @@one9seven675 Ah yes, I forgot about that. Here's the code you need!
      Add this after the other CSS.
      Change the colour to your preference.
      Make sure that you put accord in the CSS Class Name.
      .accord .elementor-accordion > div:first-of-type { display:none;}
      .accord .elementor-element .elementor-widget-container {
      border-top-style: solid;
      border-top-width: 1px;
      border-top-color: #e0e0e0;
      }

    • @one9seven675
      @one9seven675 2 ปีที่แล้ว

      @@websquadron did you actually mean this:
      .elementor-accordion > div:first-of-type {display:none;}
      .elementor-widget-accordion .elementor-element .elementor-widget-container {border-top-style: solid;border-top-width: 1px;border-top-color: #e0e0e0;}
      ?

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      @@one9seven675 I found my code worked better. Note that I have added .accord as a Class Name for the Accordion into the code.
      If your code works, then do go for it :)

  • @rasmusriis3954
    @rasmusriis3954 2 ปีที่แล้ว

    Hi
    I experience two issues with this method.
    #1 The top border of my accordions disappears when I insert the code.
    #2 I have a total of three accordions on a page but only two of my accordions work. The last one just vanishes.
    Do you have any ideas on how to solve the problem?
    Best regards
    Rasmus

    • @websquadron
      @websquadron  2 ปีที่แล้ว +2

      Make sure the last one has at least more than 1 tab content.
      See this for the border: th-cam.com/video/ycnDfUG1ZbI/w-d-xo.html

    • @rasmusriis3954
      @rasmusriis3954 2 ปีที่แล้ว

      @@websquadron I appreciate your time. This solved half of my problem, thanks, buddy. The last part where the top border is missing is getting to me. Asked you about it on your live stream and you told me to check the CSS class, which is "accord" due to the fact that I've stopped the accordion to open on the 1st tab through the CSS you show us in this video.
      I wish you a lovely Tuesday afternoon!

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      @@rasmusriis3954 What about the other style settings for the accordion? You may need to drop that to 0 in the style tab.

  • @tayorain6554
    @tayorain6554 2 ปีที่แล้ว +1

    bro can you help me i i tried the css but top border is missing and also the content is missing how to fix this ?

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      Use this code instead:
      .accord .elementor-accordion > div:first-of-type { display:none;}
      .accord .elementor-accordion {
      border-top-style: solid;
      border-top-width: 1px;
      border-top-color: #ff0000;
      }

    • @cybercrazy15
      @cybercrazy15 2 ปีที่แล้ว

      @@websquadron I used this code, but it made the fake tab appear.

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      @@cybercrazy15 Are you sure, as it's always worked for me and many others? How are you adding the code, and are you using any class names - or do you have any other CSS code applied elsewhere?

  • @websquadron
    @websquadron  3 ปีที่แล้ว +1

    We do go over the difference between an Accordion and the Toggle too.

    • @elisha770
      @elisha770 ปีที่แล้ว

      Thks 1k times. I suppose the issue for 'toggle widget' to close all others when opening one would need a solution. How would you make it so just hover would open the section and NOT having to click ?

    • @websquadron
      @websquadron  ปีที่แล้ว +1

      @@elisha770 Needs some JS that I don't have yet

    • @elisha770
      @elisha770 ปีที่แล้ว

      @@websquadron thks 👍🏻😎

  • @liaqatnasim708
    @liaqatnasim708 ปีที่แล้ว

    WEB SQUADRON! Plz HELP........ How to force 1st toggle to close by itself when we click on the other toggle?

    • @websquadron
      @websquadron  ปีที่แล้ว +2

      You should use Accordions rather than Toggle for that

    • @liaqatnasim708
      @liaqatnasim708 ปีที่แล้ว

      @@websquadron oky....👍

  • @asemabualawer
    @asemabualawer 2 ปีที่แล้ว

    hello can you solve me the problem what tha problim tabs open and dont close plese solve me

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      Are you adding accord to the class name - and then adding the code?

    • @asemabualawer
      @asemabualawer 2 ปีที่แล้ว +1

      @@websquadron Yes but when I added it it was opening and closing but when I open it again it does not open Can you help me

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      @@asemabualawer May need 1-2-1 site access but we charge for that. Sorry.

    • @asemabualawer
      @asemabualawer 2 ปีที่แล้ว

      @@websquadron thanks for help me❤️❤️🌹🌹🌹

  • @kumararvind2618
    @kumararvind2618 ปีที่แล้ว

    This code hide that accordion on which applies. The solution I found that keep first accordion blank and apply this code on that.

    • @websquadron
      @websquadron  ปีที่แล้ว +1

      I've never had that problem with the code.

  • @nicolaijunkers2853
    @nicolaijunkers2853 3 ปีที่แล้ว +3

    mate this is genius but why did you not say at the beginning that we need elementor pro for this to work. i was well excited.

    • @websquadron
      @websquadron  3 ปีที่แล้ว +1

      Oh dear - I will now make sure that I let you know from the start :)

  • @farhanwp9326
    @farhanwp9326 4 หลายเดือนก่อน

    May Allah Bless you

  • @theglobalmerchant27
    @theglobalmerchant27 2 ปีที่แล้ว

    You mentioned there is a solution for the free version?

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      Have you added the Code to your Advanced CSS for your Theme.
      Go to your Accordion and give it a Class Name of Accordstop.
      Then add this at the start of the code; .Accordstop (notice the full stop at the start).

    • @theglobalmerchant27
      @theglobalmerchant27 2 ปีที่แล้ว

      @@websquadron Thanks for the quick reply, I found where to add the class name in elementor, but where would I find the Advanced CSS for my theme?

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      @@theglobalmerchant27 Go to Wordpress > Then Appearance > Then Themes > Then Customise > Then Advanced CSS

    • @theglobalmerchant27
      @theglobalmerchant27 2 ปีที่แล้ว

      @@websquadron Cool beans thanks, mine says Custom CSS, but I am sure its the right place, now I cant find your code in the comments? sorry

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      @@theglobalmerchant27 .accord .elementor-accordion > div:first-of-type { display:none;}
      /*The bit below adds the top border back in*/
      .accord .elementor-accordion {
      border-top-style: solid;
      border-top-width: 1px;
      border-top-color: #ff0000;
      }

  • @afifaafzal975
    @afifaafzal975 ปีที่แล้ว

    where is code i didn't see it

    • @websquadron
      @websquadron  ปีที่แล้ว +2

      It was in the comments:
      Make sure that you put 'accord' in the CSS Class Name.
      .accord .elementor-accordion > div:first-of-type { display:none;}
      /*The bit below adds the top border back in*/
      .accord .elementor-accordion {
      border-top-style: solid;
      border-top-width: 1px;
      border-top-color: #ff0000;
      }

  • @ilyjax
    @ilyjax 2 ปีที่แล้ว +2

    Followed all the steps (in Elementor pro). Didn't work. Checked the video 10 times. Still didn't work.

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      Hi
      Which steps do you mean?

    • @ilyjax
      @ilyjax 2 ปีที่แล้ว

      @@websquadron all the steps mentioned in your video

    • @websquadron
      @websquadron  2 ปีที่แล้ว +2

      Hmmmmm.... Are you adding a copy of the first tab to the accordion - and then dumping the CSS Code in? Email us on info@websquadron.co.uk if you're happy with us having a look at your wp-admin site.

    • @ilyjax
      @ilyjax 2 ปีที่แล้ว +1

      @@websquadron Yes, maybe there is something going on...
      That would be great! I will e-mail you tomorrow. Thanks.

    • @websquadron
      @websquadron  2 ปีที่แล้ว +1

      @@ilyjax Great. Once we can get in, we'll check.

  • @przybylskipartners4736
    @przybylskipartners4736 ปีที่แล้ว

    What about tabs master ? :)

    • @websquadron
      @websquadron  ปีที่แล้ว +1

      Not got code for tabs yet

  • @kikidesign
    @kikidesign ปีที่แล้ว

    Thanks for this awesome video. It worked perfectly.

  • @graphicaladesign615
    @graphicaladesign615 3 หลายเดือนก่อน

    You can also add the following HTML code 'above' the accordion text box, not in it:
    body:not(.elementor-editor-active) .elementor-widget-accordion .elementor-tab-content {
    display: none!important;
    }
    window.addEventListener('load', function() {
    setTimeout(function(){
    document.querySelector('.accordion-closed-on-load').remove();
    let accordionsElems = document.querySelectorAll('.elementor-widget-accordion')
    accordionsElems.forEach(e => {
    let activeTitle = e.querySelector('.elementor-tab-title.elementor-active');
    let activeContent = e.querySelector('.elementor-tab-content.elementor-active')
    jQuery(activeContent).hide();
    activeTitle.classList.remove('elementor-active');
    activeContent.classList.remove('elementor-active');
    activeContent.setAttribute('hidden','hidden');
    activeTitle.setAttribute('aria-expanded',false);
    activeTitle.setAttribute('aria-selected',false);
    activeTitle.setAttribute('tabindex',-1);
    });
    },100);
    });