Viewing 4 posts - 31 through 34 (of 34 total)
  • Author
    Posts
  • #1314022

    Hello Guenni, thanks for your tips.
    I’ve cleaned the cache of my browser so many times that I can’t see the F5 key anymore.
    I’ve temporarily disabled the Super Fast cache extension
    I’ve changed:
    `replaceElementTag(‘.toggler’, ‘<h2></h2>’); ‘
    by
    ‘replaceElementTag(‘p.toggler’, ‘<h2></h2>’); ‘
    and still it doesn’t work.
    https://82.64.51.131/cserp/tmp/screen-p-toggler.jpg

    Any clue please?

    • This reply was modified 3 years, 4 months ago by rvga.
    #1314082

    Yesterday i tested it on my installation – both methods work on my end here.
    Did you try the other method of chlld-theme alb element? On SEO Reasons this will be the better way, because this method already creates the desired markup when generating the DOM and does not replace the p tag afterwards.

    When / Where did you load the jQuery? On Enfold Options there is the possibility to load the jQuery in the footer. But then you have to ensure that these scripts written on JQuery basis are also loaded in time afterwards.
    Try to influence the order ( priority ) of loading the script. f.e.:

    function replace_tags_with_tags(){
    ?>
    <script>
      (function($) {       
          function replaceElementTag(targetSelector, newTagString) {
            $(targetSelector).each(function(){
              var newElem = $(newTagString, {html: $(this).html()});
              $.each(this.attributes, function() {
                newElem.attr(this.name, this.value);
              });
              $(this).replaceWith(newElem);
            });
          }
    	/* replaceElementTag('h3.aviaccordion-title', '<h2></h2>'); */
    	replaceElementTag('p.toggler', '<h2></h2>'); 
        
      }(jQuery)); 
    </script>
    <?php
    }
    add_action('wp_footer', 'replace_tags_with_tags', 999);

    the 999 is a late priority and will ensure the loading after jQuery already exists : see link
    Do you see any errors on developer tools console view?

    #1314182

    Hey Guenni,
    It’s getting a little bit too technical for me, but I ended up and checked that JQuery loading stuff when I noticed that it was activated in the performances options of Enfold.
    I disabled it and finally I had my H2’s within the accordion of my test page.
    Many thanks for this last tip!
    I owe you one ;)

    #1314185

    it is simple – you can not use a function that isn’t present. That snippet is a jQuery based snippet. Without jQuery it won’t run.
    There are some good reasons to load jQuery into the footer – however, all jQuery-based functions must then be loaded temporally afterwards in order to use its functions. This could be done by setting in the add_action the priority. Low values ( default is 10) are loaded earlier – high values later.

Viewing 4 posts - 31 through 34 (of 34 total)
  • The topic ‘Accordion Title to h2’ is closed to new replies.