Home › Forums › Add-ons › Flexible Content Field › plugin shortcode doesn't work in wysiwyg field
Hello Sirs,
thank you for your great work.
I have a problem with a short code in my flexible wysiwyg field. I need an accordion area and I am using
https://wordpress.org/plugins/accordion-shortcodes/
Also I am using apply_filters for full wysiswg functions, here is my acf code
<?php
// check if the flexible content field has rows of data
if( have_rows('inhalt') ):
// loop through the rows of data
while ( have_rows('inhalt') ) : the_row(); ?>
<?php
// Standard
if( get_row_layout() == 'standard' ): ?>
<div class="content-standard">
<?php
$wysiwyg1 = get_sub_field('content-standard', false, false);
echo apply_filters('the_content', $wysiwyg1);
?>
</div>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
The html output looks ok for me
<div class="content-standard">
<div id="accordion-2" class="accordion" role="tablist">
<h3 id="accordion-2-t1" class="accordion-title open read" aria-expanded="true" aria-selected="true" aria-controls="accordion-2-c1" role="tab">Titel 1</h3>
<div id="accordion-2-c1" class="accordion-content" aria-hidden="false" aria-labelledby="accordion-2-t1" role="tabpanel" style="display: block;">
Menschen sind keine Maschinen...
</div>
<h3 id="accordion-2-t2" class="accordion-title" aria-expanded="false" aria-selected="false" aria-controls="accordion-2-c2" role="tab">Titel 2</h3>
<div id="accordion-2-c2" class="accordion-content" aria-hidden="true" aria-labelledby="accordion-2-t2" role="tabpanel" style="display: none;">
Am Beginn unserer Beratungspraxis steht ein Menschenbild...
</p>
</div>
</div>
</div>
but the accordion script does not work.
Any idea, can you help me please?
Thank you
stefan
Is the accordion script being loaded? does it appear in the html output, it should be somewhere near the bottom before the closing </body> tag.
https://wordpress.org/plugins/accordion-shortcodes/faq/
Good morning John,
thank you for yor support. Yes, the script is loading:
<script type="text/javascript">
/* <![CDATA[ */
var accordionShortcodesSettings = [{"id":"accordion-1","autoClose":true,"openFirst":true,"openAll":false,"clickToClose":false,"scroll":false},{"id":"accordion-2","autoClose":true,"openFirst":true,"openAll":false,"clickToClose":false,"scroll":false}];
/* ]]> */
</script>
<script src="http://www.dsmc-online.de/wp-content/plugins/accordion-shortcodes/accordion.min.js?ver=2.2.4" type="text/javascript">
!function(o){"use strict";var t,e;o.fn.accordionShortcodes=function(t){function e(){return o(this).hasClass("open")?h.clickToClose&&i(o(this)):(h.autoClose&&s.each(function(){i(o(this))}),n(o(this),!0)),!1}function n(t,e){t.next().clearQueue().stop().slideDown(l,function(){e&&h.scroll&&o("html, body").animate({scrollTop:o(this).prev().offset().top-h.scrollOffset},l)}),t.addClass("open read").attr({"aria-selected":"true","aria-expanded":"true"}).next().attr({"aria-hidden":"false"})}function i(o){o.next().slideUp(l),o.removeClass("open"),o.attr({"aria-selected":"false","aria-expanded":"false"}).next().attr({"aria-hidden":"true"})}var s=this.children(".accordion-title"),a=this.children(".accordion-content").hide(),c=s.first(),r=(a.first(),o(window.location.hash)),l=250,h=o.extend({autoClose:!0,openFirst:!1,openAll:!1,clickToClose:!1,scroll:!1},t);return o(".accordion").removeClass("no-js"),h.scrollOffset=0|Math.floor(parseInt(h.scroll)),r.length&&r.hasClass("accordion-title")?n(r,!0):h.openAll?s.each(function(){n(o(this),!1)}):h.openFirst&&n(c,!1),s.click(e),s.keydown(function(t){var e=t.which;(13===e||32===e)&&o(this).click()}),o(window).on("hashchange",function(){r=o(window.location.hash),r.length&&r.hasClass("accordion-title")&&(h.autoClose&&s.each(function(){i(o(this))}),n(r,!0))}),this};for(var t=0;t<accordionShortcodesSettings.length;t+=1)e=accordionShortcodesSettings[t],o("#"+e.id).accordionShortcodes(e)}(jQuery);
</script>
<script type="text/javascript">
(function() {
var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');
request = true;
b[c] = b[c].replace( rcs, ' ' );
b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs;
}());
</script>
The HTML output looks correct, the JS code is loading and I don’t see anything wrong with it, although I’m not really familiar with that plugin. The next question is, are you seeing any JavaScript errors for the page?
question is solved, it seems that it was a problem of Firefox cache or antivir software.
Thank you for your help
The topic ‘plugin shortcode doesn't work in wysiwyg field’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.