I used the the following script (only with get_permalink....) to display posts from a post type where the post author has an extra meta field on his user page:
<?php // get users from user page
$blogusers = get_users();
foreach ($blogusers as $user) {
if(get_field('races','user_' . $user->ID)) {
while(the_repeater_field('races','user_' . $user->ID)) {
$signed_up = get_sub_field('race_name', $post_object->ID);
if($original_id == $signed_up->ID) { //original ID is the race_name post we are on
$user_info = get_userdata($user->ID);
$arg = array(
'post_type' => array ('members'),
'post_status' => array( 'publish'),
'posts_per_page' => 200,
'author' => $user_info->ID
);
$arg_query = new WP_Query();
$arg_query->query( $arg );
echo $total = $arg_query->post_count;
} else {
}
}
}
} ?>
While it worked to display titles of the posts from the members post type, I can't get my head around to count these posts. It shows: 1 1 1 instead of 3 and so on. How can I change the foreach to work properly?
$total=$total+1
inside loop and then echo that outside loop.$total = $arg_query->current_post + 1;