Skip to content

Create accordions in the WordPress editor using a PHP shortcode. Each <h3> becomes a title, and the following content forms that section’s panel.

Notifications You must be signed in to change notification settings

lazyZ33/wysiwyg-accordion-shortcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

This is a PHP Shortcode allowing us to create an accordion directly in the WordPress WYSIWYG editor using the structure: [accordion_block]...[/accordion_block].Within the shortcode, all <h3> tags are automatically mapped as accordion titles, with any content between two <h3> tags serving as that title's associated content.The PHP code processes this input and generates the necessary HTML markup.jQuery handles interactivity, implementing an exclusive accordion pattern where only one item can be open at a time.

The component's appearance is controlled by CSS, which must be adjusted to your specific design requirements as styling is subjective. Dummy Use Case (Creating a FAQ Section)You can paste the following content directly into your WordPress page editor (in the Text or Code view) and the shortcode will transform it into a functional, styled accordion:

[accordion_block]
    <h3>What treatment methods are offered?</h3>
    <p>We offer a comprehensive range of programs, including outpatient, intensive outpatient (IOP), and specialized dual-diagnosis treatment for co-occurring disorders.</p>
    <ul>
    <li>Cognitive Behavioral Therapy (CBT)</li>
    <li>Dialectical Behavior Therapy (DBT)</li>
    <li>Eye Movement Desensitization and Reprocessing (EMDR)</li>
    </ul>

    <h3>How long does the admissions process take?</h3>
    <p>The initial admissions verification usually takes less than 20 minutes. We guide you through checking your insurance coverage and setting an intake date as quickly as possible.</p>

    <h3>Is my information kept confidential?</h3>
    <p>Absolutely. We strictly adhere to all HIPAA regulations, ensuring all personal health information and treatment details remain confidential and secure.</p>
[accordion_block]

This will render a fully interactive FAQ accordion on your live page.

About

Create accordions in the WordPress editor using a PHP shortcode. Each <h3> becomes a title, and the following content forms that section’s panel.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published