Home / Admin / How to Display a List of WPForms Using a Shortcode
Duplicate Snippet

Embed Snippet on Your Site

How to Display a List of WPForms Using a Shortcode

This snippet will create a new shortcode that can display all your WPForms forms.

<10
Code Preview
php
<?php
/**
* Create shortcode to display all form titles in a list.
*
* Basic usage: [wpforms_all_forms]
*
* @link https://wpforms.com/developers/how-to-display-a-list-of-wpforms-using-a-shortcode/
*/
add_shortcode('wpforms_all_forms', function() {
    $args = [
        'post_type' => 'wpforms',
        'post_status' => 'publish',
        'posts_per_page' => -1,
    ];
    $posts = wpforms()->form->get();
    $forms = wp_list_pluck($posts, 'post_title');
    return implode('<br>', $forms);
});

Comments

Add a Comment