To display the number of entries that have been submitted for a form, we will create a reusable shortcode. Add the following code to your theme functions.php file (or create a plugin for it).
1 2 3 4 5 6 7 8 9 | add_shortcode('quform_entry_count', function ($atts) { $atts = shortcode_atts(array( 'id' => '0' ), $atts); $repository = Quform::getService('repository'); return $repository->getEntryCount($atts['id']); }); |
add_shortcode('quform_entry_count', function ($atts) { $atts = shortcode_atts(array( 'id' => '0' ), $atts); $repository = Quform::getService('repository'); return $repository->getEntryCount($atts['id']); });
1 2 3 4 5 6 7 8 9 10 11 | function my_quform_entry_count($atts) { $atts = shortcode_atts(array( 'id' => '0' ), $atts); $repository = Quform::getService('repository'); return $repository->getEntryCount($atts['id']); } add_shortcode('quform_entry_count', 'my_quform_entry_count'); |
function my_quform_entry_count($atts) { $atts = shortcode_atts(array( 'id' => '0' ), $atts); $repository = Quform::getService('repository'); return $repository->getEntryCount($atts['id']); } add_shortcode('quform_entry_count', 'my_quform_entry_count');
You can then use the the shortcode as shown below in any shortcode-enabled area (for example in any post or page content or within the content of an HTML form element).
[quform_entry_count id="1"]
- Replace the number
1
with the form ID