How to Display Entry Submissions Count for a Specific Form

Introduction

Interested in showcasing the total count of entries for a particular form on your website? The ability to display the total number of form entries can be valuable, especially if you’re running surveys or contests and want to highlight participant engagement. In this tutorial, we’ll walk you through the process of displaying your entry count using PHP, so you can effectively communicate the level of engagement on your site.

Creating a shortcode

Creating a shortcode simplifies the process of displaying the total entry count across various areas of your website, especially if you have multiple forms in use.

To make use of this shortcode, you must first create it, enabling you to insert it seamlessly into any page, post, or widget area on your site. Below is the essential code snippet to integrate into your website.

If you’re unsure about how to add code snippets to your site, please consult our tutorial for step-by-step guidance:

/**
 * Shortcode that displays the number of completed entries for a form.
 *
 * Usage:  [wpforms_entry_total form_id="FORMID"] - FORMID is the form ID.
 *
 * @link   https://wpforms.com/developers/display-entry-submissions-count-for-a-specific-form/
 */

function wpf_dev_form_entry_total( $atts ) {

	$args = shortcode_atts( array(
        'form_id' => ''
    ), $atts );

    if ( empty( $atts[ 'form_id' ] ) ) {
    	return;
    }

    $total = wpforms()->entry->get_entries( array( 'form_id' => $atts[ 'form_id' ] ), true );

    return absint( $total );
}
add_shortcode( 'wpforms_entry_total', 'wpf_dev_form_entry_total' );

To utilize the shortcode, simply place it within any post, page, or widget area on your site using a WordPress Shortcode block:

[wpforms_entry_total form_id="FORMID"]

Just ensure that you replace FORMID with the actual form ID you wish to display. If you require guidance on finding your form’s ID, refer to this article. For the purposes of this tutorial, we’ve used a form ID of 3967 as an example.

For our tutorial, we want to display how many children have signed up for our class so we will add the shortcode right in line with the text.

add the shortcode to your page inline with your text

Now when visitors see your page, they’ll see the total number of entries we have received for our form.

the visitors will see the display entry submissions count along with your form

And that’s all you need in order to display your entry submission count on your WPForms. Would you like to create a shortcode to display your form entries on the front end of your site? Take a look at our tutorial on How to Display Form Entries.