Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    • Documentation
    • Support
    • Account

Shortcode: Display Number of Entries Submitted

Extends the [gravityforms] shortcode, providing a custom action to retrieve the total entry count for a given form. Also supports retrieving entry counts by entry status (i.e. "trash", "spam", "unread", "starred").

Last updated September 21, 2021 | Written by Jordan Smith 62 Comments

Are you limiting how many entries can be submitted and looking for a way to display the number of entries left? We’ve got a shortcode for that too!
View CodeDownload Code

After installing this snippet, you will be able to display the number of form entries that have been submitted with the following shortcode:

[gravityforms action="entry_count" id="your_form_id"]

Getting Started

  1. Check requirements

    • Make sure you have Gravity Forms installed and activated.
      • Already have a license? Download Latest Gravity Forms
      • Need a license? Buy Gravity Forms
  2. Install the snippet

    • Copy and paste the entire snippet into your theme’s functions.php file.
  3. Configure the shortcode

    • For the basic version just enter your form id and the shortcode will return the total number of submitted entries!
    • If you would like to have a little more control over the type of entry being pulled, read on for some additional configuration options.
    • View available shortcode attributes

Usage Examples

Basic Usage

[gravityforms action="entry_count" id="your_form_id"]

[gravityforms action="entry_count" id="2"]

Would you like to use this shortcode in the sidebar of your website? Check out the Shortcode Widget plugin.

Unread Entries, Comma Format

[gravityforms action="entry_count" id="2" status="unread" format="comma"]

Display the entry count for unread entries using comma format (i.e. “1,001”).


Trashed Entries, Decimal Format

[gravityforms action="entry_count" id="2" status="trash" format="decimal"]

Display entry count for entries in the trash using decimal format (i.e. “1.001”)


Shortcode Attributes

  • id (int) (required)

    The ID of your form. Defaults to false.

  • status (string) (optional)

    The entry status type that you would like to display number of entries submitted for. Defaults to “total.” Options include: “total”, “unread”, “starred”, “trash”, and “spam”.

  • format (string) (optional)

    The type of formatting to be used when displaying the entry count. Defaults to false. Options include: “comma” and “decimal”.

How’d we do?

If you use it and like it, let us know. We’d love to hear the different ways you found this code useful!

Filed Under: Uncategorized

Comments

  1. Paolo says

    December 10, 2021 at 10:29 am

    Hello! and how do I set the counter to “0” again?

    Can it be reset or is that not possible?

    Thanks

    Reply
    • Dario Space says

      December 10, 2021 at 10:33 am

      Hi Paolo,

      This snippet counts how many entries were submitted. If you need to tweak the snippet you can get in touch with us via our support form if you have an active Gravity Perks license so we can take a closer look at your setup.

      Best,

  2. Dean Suhr says

    September 20, 2021 at 5:09 pm

    I did not want the count to display until it had reached a certain threshold. I tweaked David’s fine script to provide for this. Two optional fields are used: display_min (a number) and display_min_alt_text (alternate text).

    http://snippi.com/s/d32esuf

    Dean

    Reply
    • Dario Space says

      September 21, 2021 at 7:45 am

      Hi Dean,

      Thanks for sharing with the community. We already followed up on this via email, but I wanted to post this in the comment thread so other customers could see it.

      Cheers,

  3. Steven Grimmer says

    July 9, 2021 at 7:25 am

    Hi there

    Nice bit of code. I am showing the number of entries of the form – all good. But I also want to add a number to this every so often that reflects offline forms that are physically collected. Is there a way to do this?

    Reply
    • Scott Buchmann says

      July 9, 2021 at 11:04 am

      Hi Steven,

      We don’t have a ready solution for this one. If you don’t collect many offline, you could enter the physical form data into the Gravity Form.

  4. Mareks says

    October 12, 2020 at 3:56 pm

    Is it possible to show only last 7 days entries?

    Reply
    • Scott Buchmann says

      October 12, 2020 at 5:05 pm

      Hi Mareks,

      This isn’t currently supported. If you are a Gravity Perks customer with an Advanced or Pro license, drop us a line and we can look into adding support for this.

  5. Rob says

    July 23, 2018 at 2:30 pm

    Hello,

    When I try to run this shortcode via do_shortcode, I get an error.

    Here’s the PHP I’m using:

    echo do_shortcode(“[gravityforms action="entry_count" id="1" format="comma"]“) . ‘ people have taken the pledge to…’;

    I’ve tried to escape the quotes inside the do_shortcode function, but when i do that the shortcode isn’t even recognized.

    Here’s the error I’m getting:

    Parse error: syntax error, unexpected ‘entry_count’ (T_STRING), expecting ‘,’ or ‘)’ in pledgetally.php on line 3

    Reply
    • David Smith says

      July 24, 2018 at 10:58 am

      You’ll need to use single quotes to wrap the shortcode.

      '[gravityforms action="entry_count" id="1" format="comma"]'

    • Rob Monti says

      July 24, 2018 at 3:06 pm

      I actually tried that. When I did that the error said that do_shortcode was an unrecognized function.

  6. Rochel says

    July 13, 2018 at 7:55 pm

    I’m currently using this shortcode but I’m wondering how to tweak it so it can display the number of entries from multiple forms. How can I add multiple for ids?

    Reply
    • Joeri says

      November 17, 2020 at 7:15 am

      I would also like to know if this is possible… I am having a case where I need to show the total number of entries from multiple forms that are related to each other.

    • Samuel Bassah says

      November 17, 2020 at 9:13 am

      Hi Joeri,

      This isn’t currently supported. If you are a Gravity Perks customer with an Advanced or Pro license, drop us a line and we can look into adding support for this.

      Best,

  7. Adam says

    March 5, 2017 at 8:59 am

    This looks great, Is there anyway to display entries sent to a certain author email ? I currently use the below code to email the author of a particular page when a form entry is made.

    What id like to do is create a page where that author can then see the entries which has been submitted to him, your code seems to do that, but obviously it would display ALL entries for that form, could someone help with what code id need to use narrow it down only authors saw their own entries from the same form.

    Reply
    • David Smith says

      March 5, 2017 at 6:38 pm

      It looks like this might help: https://wordpress.org/plugins/gravitywp-count/

  8. Alex says

    February 3, 2017 at 12:56 am

    Hi David! How to display sum of entries from date range? How to set start and end date and get the amount on a specific field?

    Reply
    • David Smith says

      February 3, 2017 at 10:26 pm

      Hi Alex, we do not currently have a solution for this.

    • Alex says

      February 3, 2017 at 11:37 pm

      Today I modified this shortcode and it works as [donations form=9 start_date=”2017-02-01″ end_date=”2017-02-03″] But I don’t know how to make input on HTML page:

« Older Comments

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Recent Posts

  • Spotlight: Gravity Forms Media Library 🤝 Advanced Custom Fields
  • How ANM Powers Internal Finances with GP Unique ID
  • New Release: Gravity Forms QR Code Beta 1
  • How Farbie.at uses GP Inventory to manage over one thousand parties a year
  • Spotlight: Building a Loan Calculator with GP Advanced Calculations

Categories

  • How To (73)
  • News (25)
  • Plugins (19)
  • Releases (13)
  • Resource (3)
  • Snippets (50)
  • Spotlights (15)
  • Tutorials (57)
  • Uncategorized (4)
  • Updates (152)

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2022 · Powered by WordPress · Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Terms & Conditions of Use
  • Privacy Policy
  • Cookies Policy

Want to become a
Gravity Forms wizard?

Join 15,000 readers and be the first to know of legendary discounts, new releases, free snippets, and other secret sorcery!

  • Gravity Perks
    ▼
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    ▼
    • Documentation
    • Support
    • Account