wp query - How do I get all authors posts of a custom post type outside loop

admin2025-06-06  8

I'm trying to create a utility script that to add some metadata into all posts of a certain post type. Right now I have it set up to loop through all users

$blogusers = get_users(array(
        'role'     => 'freelancer'
));

for( $i = $index;  $i < count($blogusers); ++$i) {

    $user = $blogusers[$i];

    $userID = $user->ID; // set to user id

    $profile_id = get_user_meta( $userID, 'user_profile_id', true);

    $user_reach = get_post_meta( $profile_id, 'total_reach', true);

    $user_engagement = get_post_meta( $profile_id, 'total_starpower', true);

    $user_rating = get_post_meta( $profile_id, 'rating_score', true);

    write_log("working on " . $user->user_login);
}

I want to copy user_reach, user_engagement, and user_rating into the meta of all of the users posts of BID post type.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749186947a317091.html

最新回复(0)