Hi @rsm:
There are probably better ways, using the WordPress API, but since I know SQL so well this immediately came to mind:
function total_published_authors() {
global $wpdb;
$sql =<<<SQL
SELECT COUNT(*) AS total_published_authors FROM (
SELECT DISTINCT
{$wpdb->users}.ID
FROM {$wpdb->users}
INNER JOIN {$wpdb->posts} ON {$wpdb->posts}.post_author={$wpdb->users}.ID
WHERE
{$wpdb->posts}.post_status="publish"
GROUP BY
{$wpdb->users}.ID
) x
SQL;
return $wpdb->get_var($sql);
}
If I come up with a better way I’ll post it too.
Related Posts:
- Return $post_id when DOING_AUTOSAVE?
- Including Angle Brackets In Pre Sections
- Anchor Text code string is automatically modified by WordPress
- WordPress is converting & to & inbetween [code] brackets
- Notice: Undefined property: wpdb::$current_post What can be wrong?
- Where to save common libraries?
- source code: WP_INSTALLING vs. WP_SETUP_CONFIG in setup-config.php
- Sublime Video: Playlist which gets all attached videos
- Code Friendly Block Quotes
- Remove line breaks from ?
- How to fix a “globals” issue to avoid a rejected theme?
- Need resource on available functions and objects
- WordPress wp_insert_post() returns 0 but not not wp_error
- I want to remove the home page header image from all other pages
- Proper implementation/use of code/syntax highlighting
- How to remove all comments from JS, HTML, CSS files?
- What data validation we must use in different contexts?
- Need To Post Unformated Code
- Sidebar login: How do I get the username to show after “Welcome”?
- How to manage multiple wordpress project with shared code base
- Block IP Addresses using Code [closed]
- Why does HTML entities are still encoded in Code Block?
- How to create a checkbox to show/hide a field in WooCommerce checkout [closed]
- how to display google maps with javascript
- How to pass https://achecker.ca/ validator? [closed]
- How to write custom code on WordPress?
- Remove Metaboxes
- Google analytics won’t work in wordpress
- Where do I add an action hook & callback in my theme?
- How do I reset my footer.php to its original state? (theme: Origami)
- Commenting out in HTML editor breaks template
- wordpress prepare error
- Adding code to send referrer on login page
- Table styles disappear when updating content
- Manage recurring event time
- wp_editor save all content
- Need an elegant solution to declare the value of two variables based on the count of the post
- How to insert integration code for CRM?
- A good way to include snippets of code in both posts, pages and Event Manager Template files?
- Anchor Text code string is automatically modified by WordPress
- Return $post_id when DOING_AUTOSAVE?
- Changes in code only show after changing theme
- Code Highlighting in BlockQuote
- feed url problem
- Where do I go to add a tag before the closing body tag?
- How to get a variable number of posts per post type on the main loop?
- Create custom [sourcecode] shortcode, the right way?
- how to group custom post types
- How do i structure my theme folder to avoid one huge list of files
- Editing Source Code in WordPress
- API integration with WordPress
- write in functions.php
- Pinterest Integration Using functions.php
- Successful or Error Message after running mysql code in functions.php
- Beautify WordPress HTML output without any plugins
- Date/time limitation of posts where function must be executed
- How to implement Google reCaptcha without installing a plugin?
- Connect Second Database to WordPress
- If in category to be inside of a function
- Hiding styles from Facebook
- Hide wordpress field if data is empty in post!
- code suddenly appearing from my tempate second loop
- Latest post in a specific menu
- Most liked page not displaying posts
- How to save checkbox values for logged in users?
- How to add an automatic refresh in WordPress for a Page/Post or an embedded OneDrive/Excel HTML Code?
- WordPress change Language not working
- How can this crude function be improved?
- How to run a function in every page, every device
- WordPress code editor messed up my code!
- Loop don’t work within single.php page
- How to Configure Events List in WordPress to Disappear Event Once Date is Past
- Code snippet to show current php version inside “At a Glance” box in admin
- How to run wp cli from a wp hook?
- Fatal error: Uncaught Error: Call to undefined function get_header() [closed]
- Add Permalink to Post Thumbnail, syntax code issues
- I want a widget to appear on only one page
- Allow tags between shortcode in comments
- Author & date removal
- PHP code snippet to remove microdata
- Counting number of posts in multiple (sub)categories using shortcode
- Reorder a page of posts of a certain taxonomy/value by a custom field
- remove edit link only for published post and pending post
- Changing the Default New User Notification Email
- JQuery script working locally on desktop, not working on WordPress + Divi
- WordPress Sticky Post Count “Fix” Breaking Pagecount by 72 pages!
- How can I use javascript in specific posts without relying on a plugin?
- How to add specific posts to specific pages in WordPress?
- Code for cron to delete posts that contain specific expression (e.g. “unable to fetch” every 30 minutes
- Website Tablet Check Out Field Issue
- style.min.css code issue
- how to run a php code in widget?
- Pull ‘Popular Posts’ within specific timeframe
- how to add number value in front for variable [closed]
- widget that will do shortcodes that user inputs
- How to add a class name to the ancestor of a post?
- Themes with variable width or single columns? I want to display source code
- Creating a press page for our project
- How do I upload my WordPress code files from previous website onto local host WordPress website?
- I want create woocommerec match products columns