Duplicate posts in my custom loop

You’re trying to loop through the thumbnail, which doesn’t make any sense: foreach ($thumbnail as $thumb){ And then inside the loop you’re referring to $thumbnail again anyway: <img class=”thumbnail zoom” src=”https://wordpress.stackexchange.com/questions/280435/<?php echo $thumbnail[0];?>” > wp_get_attachment_image_src() returns an array that looks like this: array( 0 => ‘http://website.com/path/to/image.jpg’, // URL 1 => 150, // Width 2 => … Read more

How to get all users by user_login as a json_encode array?

Try this one: function prefix_get_users(){ $args=array( ‘blog_id’ => $GLOBALS[‘blog_id’] ); $all_users=get_users($args); $arr=array(); foreach ($all_users as $val) { $arr[]=$val->data->user_nicename; } die(json_encode( $arr )); } Reference: https://codex.wordpress.org/Function_Reference/get_users