1. Go to this page and download the library: Download meom/meom-user-query library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/**
* Modify WP User Query data to return HTML.
*
* @param array $data Data inside loop.
* @param object $user_query WP User Query.
* @param array $args Arguments.
* @return array Modified data.
*/
function prefix_modify_user_data( $data, $user_query, $args ) {
if ( ! empty( $user_query->get_results() ) ) {
$html = '';
ob_start();
foreach ( $user_query->get_results() as $user ) {
// Change this to your needs.
// In this example we pass user ID to the template and do the markup in there.
get_template_part( 'partials/user/user-item', null, [ 'author_id' => $user->ID ] );
}
$html .= ob_get_clean();
$data['html'] = $html;
wp_reset_postdata();
}
return $data;
}
add_filter( 'wp_user_query_to_rest_api_after_loop_data', 'prefix_modify_user_data', 10, 3 );
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.