# Block Pattern: FAQ With Expandable Answers

> Adds an FAQ pattern built from core Details blocks, so visitors click a question to reveal its answer, with no plugin and no JavaScript.

- Type: PHP
- Runs: Run everywhere
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: patterns, faq, details, block-editor
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/pattern-faq-details/

## Code

```php
add_action( 'init', function () {
    if ( ! function_exists( 'register_block_pattern' ) ) {
        return;
    }

    if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( 'wpide-sections' ) ) {
        register_block_pattern_category( 'wpide-sections', array( 'label' => 'Site Sections' ) );
    }

    $questions = array(
        'How long does delivery take?'    => 'Most orders arrive within 3 to 5 working days.',
        'Can I change my order?'          => 'Yes, reply to your confirmation email within 24 hours and we will update it.',
        'Do you ship internationally?'    => 'We ship to most countries in Europe and North America.',
        'What is your returns policy?'    => 'Return any unused item within 30 days for a full refund.',
    );

    $items = '';
    foreach ( $questions as $question => $answer ) {
        $items .= '<!-- wp:details --><details class="wp-block-details"><summary>' . esc_html( $question ) . '</summary><!-- wp:paragraph --><p>' . esc_html( $answer ) . '</p><!-- /wp:paragraph --></details><!-- /wp:details -->';
    }

    register_block_pattern( 'wpide/faq-details', array(
        'title'       => 'FAQ: expandable answers',
        'description' => 'Frequently asked questions using Details blocks.',
        'categories'  => array( 'wpide-sections' ),
        'keywords'    => array( 'faq', 'questions', 'accordion' ),
        'content'     => '<!-- wp:group {"layout":{"type":"constrained"}} --><div class="wp-block-group"><!-- wp:heading --><h2 class="wp-block-heading">Frequently asked questions</h2><!-- /wp:heading -->' . $items . '</div><!-- /wp:group -->',
    ) );
} );
```

## Notes

Add or remove questions by duplicating a Details block in the editor.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Block Pattern: FAQ With Expandable Answers" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
