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?
- Edit plugin without hooks in functions.php
- Making plugin unique to not conflict with plugins with the same name
- How to find out if option exists but is empty?
- Search and replace text across all posts
- Is dynamic forms/entries possible in Widget?
- How to get posts by content?
- Trigger a custom wordpress plugin with a linux cron
- update_meta_user difference in i:1 and b:1, how to write b:1
- Registration Form Validation in wordpress
- Add_rewrite_rule doesn’t add custom url in plugin
- How to add inline css/js inside a shortcode
- Is this plugin being loaded before file.php, subsequently not allowing me to use certain functions?
- How to integrate plugin in WordPress theme
- How do I write into a file (css)
- Loco Translate: Custom Post and Custom Taxonomy Labels not translated in wp-admin menu
- Where should I save an API key of my user when installing my plugin?
- How to make a customize role and view a specific plugins base on that role?
- Allow users of my plugin to define their own shortcode rather than use mine?
- CRUD and Frontend show from a custom table without shortcode
- Map Custom Registration Fields to WordPress User Roles
- How can I make 2 plugins that include different versions of a framework to both use the latest version?
- Add Plugin options as subpage to Theme options page
- Image upload and download from front-end
- How do I run SQL queries on a WordPress web page? [closed]
- custom payment gateway in woocommerce failed to connect to remote api server
- correct way to include a library(and its dependent libraries) in wordpress development
- Issue Tracker from pre exsisting table [closed]
- Ajax call returning 0
- Git Hosting for WordPress SVN Plugin Repository [closed]
- WordPress plugin admin html being shown in Customizer iframe
- WordPress Widget – Saving multidimensional arrays into $instance
- Plugin Options not being output
- Stop Plugin from Getting Styles from Other Plugin
- Default taxonomy template in plugin, override in theme
- How to add support for caching plugins for my own plugin?
- WordPress Site is Broken, Cannot see wp-admin page [closed]
- wp_loaded with static Singleton
- How to remove a CPT Menu from the Root Admin only
- Get post_id on clicking a link in WordPress
- WordPress.org: How to add a plugin for certain countries?
- How to remove menus items from Menu section from WordPress theme customizer
- Wp Debug Enabled True Notices and Warning
- Plugin generated unexpected output – No PHP errors
- Extending a theme: build new features as plugin or core modules?
- help intercepting save_post through plugin
- best way to run a php script away from the template?
- Scrape key check failed. Please try again
- Add a new category for posts
- How to save Setting pages data to the database?
- Prevent WordPress from sending set-cookie http header
- Is there any way to sync Facebook Comments and with comments on WordPress website?
- how to auto random increment for post view
- Woocommerce convert simple products to variations
- How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?
- Block content rendering on the top just below body tag
- WordPress Thickbox Navigation Issue in Gallery
- How to save the option’s new values plus old value without overwrite old one
- Not displaying Woocommerce product page in lightbox
- WordPress “template_include” Filter Not Working
- WordPress Media Uploader : How to add custom button on featured image tab
- Change pricing in Woocommerce based on Category and Product [closed]
- Can we validate data from jquery
- WordPress not displaying information on post sent from custom admin form
- Getting error “The package could not be installed. PCLZIP_ERR_BAD_FORMAT ”
- Building a simple “settings” plugin to change textstrings on the home page
- Couldn’t find a documentation for a filter API in plugin development
- My wordpress website admin panel loads very slow, what can i do about that? [closed]
- Modifying lightbox plugin to allow for quoting, Does this exist? [closed]
- What can I do to customize a widget provided with this plugin? from where have I to start?
- How to escape html code?
- WP Elementor Pro causing crtical failure on website
- Function not being called on form submit, only blank admin-post.php page
- Display Any Field fromAdmin Panel in Frontend via Shortcode?