Four changes to your script. Limit $users to users with ‘administrator’ role. Removed line if($user->caps['Administrator']!=1) continue;
as every user is an administrator. Changed ‘post_per_page’ to -1, to process all posts. Added wp_reset_postdata();
after each loop:
$users = get_users( array( 'role' => 'administrator' ) );
foreach ( $users as $user ) {
$query = new WP_Query( array(
'posts_per_page'=>-1,
'author' => $user->ID
)
);
if( $query->have_posts() ) {
while( $query->have_posts() ) {
$query->the_post();
get_template_part('content', 'postlist');
}
} else {
get_template_part('content', 'none');
}
wp_reset_postdata();
}
Make sure that you reach right template in get_template_part('content', 'postlist');
statement.
Related Posts:
- How does WordPress handle MySQL row lock errors?
- $wpdb->get_results() does not fetch results with unicode ‘WHERE’ clause
- Help With MySQL to WPDB Query Conversion
- Creating mySQL procedure with $wpdb
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- WordPress plugin creation how to execute .sql in order to insert multiple rows at activation of plugin
- Plugin: register_deactivation_hook works perfectly well, while register_activation_hook suddenly stopped working
- Insert data from .sql file in wordpress plugin
- WordPress Backend HA (Automatic failover)
- DB Query not working in Plugin
- Way to send multiple values for column to MySQL?
- WordPress plugin: efficient way to store large data
- Plugin generating unexpected output – on WP mysql dump import
- Can’t create tables with my plugin
- Integrating Custom Database with WordPress
- How to display results from a data table with an encrypted user id?
- How to get the custom field value using SQL query
- Need to know if my approach to designing a geneaology plug-in for wordpress makes sense
- I created a plugin with ‘view page’ that uses MYSQL + PHP. When I use wp_insert_post(), it turns everything to HTML
- WordPress UPDATE queries on MySQL database stuck
- Resetting AUTO_INCREMENT primary key
- Re-writing MySQl query for execute faster
- Create Database Tables on Plugin Activation hook
- Linking Plugin Files to WP
- how to search through plugin in wordpress cimy-user-extra-fields?
- Get all the related data from WordPress DB
- How can I delete the options from DB when the plugin is deleted?
- WP_Query does not return the result even if the data is present in the database
- Updating wp_postmeta from meta_keys and meta_values from another table having price and sku only
- WP Post Template – Templates in own folder
- Register Page Template from Plugin
- Private Plugin Updates – Localhost
- How to change custom post type pemalink Hierarcy
- Any hook for pre-plugin-update -either bulk or single plugin update
- Get plugin option in another PHP file
- wp_create_nonce function doesn’t work inside a plugin?
- Test files for plugin development
- Input with spaces in Shortcode attributes overwritten by defaults
- Unable to override pluggable function wp_mail
- Avoid class name collision when using third party libraries in plugins?
- How to create custom tables in WordPress using my own plugin?
- New User Form – Custom Menu Page
- Own plugin corrups plugin-activation
- wordpress plugin is not activating from widget
- All Users > User List > Update User Meta Field Inline
- Checking instances of scripts in wp_head
- How to save post change url youtube link?
- Best approach to fetch data from wp options to js file or php file
- Correct way to perform non-cacheable DB query
- Allow users of my plugin to define their own shortcode rather than use mine?
- Is it possible to create Custom Post plug-in?
- uninstall.php file in Plugin to clean DB
- Archive – same title for the first two posts
- Creating a plugin to sanitize comment and the url field before display only
- Edit Yoast SEO breadcrumbs output [closed]
- Creating plugin using simple_html_dom parser?
- Object Oriented Plugin not working
- How to simultaneously access the same MySQL database in the main column and sidebar of WordPress?
- Does WP identify plugin by plugin name or plugin_basename?
- switched from query_posts to WP_query, not working now?
- Making a plugin only available on the front-end for the logged in super admin
- Create entire wordpress as a github repositery?
- When to load auto-login code?
- AJAX search posts and pages
- How to find the origin of a file upload from within wp_handle_upload?
- How would I go about creating a user ranked post popularity page?
- CSV file generation failing
- Updating the Drag-To-Share eXtended share URLs?
- finding whether request is for post, and post id
- Building plugin with changeable custom post type values…advice needed
- How to get all of the activate_plugin action parameters?
- __callStatic method handler passed to add_action causes bug in PHP
- Enqueue WordPress plugin scripts below all other JS
- Display update notification messages like ‘What’s New’
- How to add Internationalization in WordPress using Javascript/React?
- CRUD and Frontend show from a custom table without shortcode
- How to get specific setting by settings_fields()?
- Save / Show multi line text in metabox
- how to disable blockrenderAppender inside all Innerblocks?
- why doesn’t this update part of this plugin work? it take me to nothing here page
- Redirection of users away from wp-admin (but not administrators)
- WordPress Gutenberg react make import of __experimentalUseInnerBlocksProps which is no more experimetal
- Using a custom plugin to capture input data via Ajax and PHP
- Python with wordpress plugin
- Display post lists in 2nd paragraph
- Map Custom Registration Fields to WordPress User Roles
- Not able to add option in Sub-Menu under page
- How to stop activating a plugin and show admin notice when dependent plugins minimum version is not met
- Using a post-signup hook to get user details
- How to apply a patch via plugin?
- Fixing WordPress’s Bug (failed to send buffer of zlib output compression) results in “White Screen of Death”
- Disable woocommerce cookies and delete cart data automatically
- Ajax contact form widget plugin data not insert in database
- link bbpress forum discussion to blogposts
- Install Plugin via Code
- code is working properly in Core PHP but writing coding in WordPress
- Combine scripts from all extensions of the plugin when an extension is activated
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- Prevent duplicate records in plugin table
- Send Custom welcome email to specific user group