Home › Forums › Newsletter Plugin Support › displaying the count of subscribers on a website
How should I go about displaying the amount of people that have subscribed the newsletter on a website?
There is no such count, actually, you should execute a query to get it.
I’d be quite keen to get this figure on my website.
Can you tell me what are the database table names we would be to execute this query.
I have never done this before but always willing to dive into this type of stuff.
wp_newsletter. wp_ can be different in your blog since it’s the configured table prefix for your installation.
For anyone looking for this, it took me a while to figure out. Why this is not offered as a simple API call is weird. However, you can do this with the following PHP query:
$get = $wpdb->get_results(" SELECT * FROM ".$wpdb->prefix."newsletter WHERE status='C' ");
echo count ($get);
This queries the Newsletter database and only returns Confirmed subscribers. Then the count line gives you the total array size.
Use a wordpress plugin like XYZ PHP Code to convert that PHP into a usable shortcode. Once you have that done, use the shortcode anywhere you want within your WP site.
Hi, if you have many subscriber that query will run in a out of memory. Use this:
$count = $wpdb->get_var(” SELECT count(*) FROM “.$wpdb->prefix.”newsletter WHERE status=’C’ “);
Terms and Conditions
Sign up for latest news, important updates and special tutorials.
© 2023 Web Agile S.a.s. di Fietta Roberto - VAT IT-03809490240