# Show an ACF Repeater as a List

> Adds an [acf_list name="features" sub="text"] shortcode that turns a repeater field into a bulleted list, with an optional second sub field shown in bold.

- Type: PHP
- Runs: Run everywhere
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: acf, repeater, shortcode
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/acf-repeater-list-shortcode/

## Code

```php
add_shortcode( 'acf_list', function ( $atts ) {
    $atts    = shortcode_atts( array( 'name' => '', 'sub' => '', 'label' => '', 'post_id' => 0 ), $atts, 'acf_list' );
    $post_id = $atts['post_id'] ? absint( $atts['post_id'] ) : get_the_ID();

    if ( ! $post_id || ! function_exists( 'get_field' ) || ! is_post_publicly_viewable( $post_id ) ) {
        return '';
    }

    $rows = get_field( sanitize_key( $atts['name'] ), $post_id );

    if ( ! is_array( $rows ) || ! $rows ) {
        return '';
    }

    $sub   = sanitize_key( $atts['sub'] );
    $label = sanitize_key( $atts['label'] );
    $items = '';

    foreach ( $rows as $row ) {
        if ( ! is_array( $row ) || ! isset( $row[ $sub ] ) || ! is_scalar( $row[ $sub ] ) ) {
            continue;
        }

        $prefix = ( $label && isset( $row[ $label ] ) && is_scalar( $row[ $label ] ) ) ? '<strong>' . esc_html( $row[ $label ] ) . ':</strong> ' : '';
        $items .= '<li>' . $prefix . esc_html( $row[ $sub ] ) . '</li>';
    }

    return $items ? '<ul class="acf-list acf-list-' . esc_attr( sanitize_html_class( $atts['name'] ) ) . '">' . $items . '</ul>' : '';
} );
```

## Notes

Example: [acf_list name="specs" label="name" sub="value"]. Repeaters need ACF PRO.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show an ACF Repeater as a List" 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/
