Proper now I am utilizing this complicated Question.
First I question customers after which question their posts by particular customized taxonomy:
<?php
$args = array(
'meta_query' => array(
//Purchase visitors if UserFunds is bigger than 0
array(
'key' => 'userfunds',
'worth' => '0',
'examine' => '>',
),
),
'quantity' => 999999999,
'orderby' => 'rand',
);
$my_user_query = new WP_User_Query( $args );
$advertisers = $my_user_query->get_results();
if ( ! empty( $advertisers )): ?>
<?php foreach ( $advertisers as $advertiser ):
setup_postdata( $advertiser ) ?>
<!-- If Advertisers with Funds exist, filter out marketing campaign posts -->
<?php
$advertiser_info = get_userdata( $advertiser->ID );
// Get posts with customized taxonomy 'sort' => 'marketing campaign'
$posts = get_posts(array(
'writer' => $advertiser_info->ID,
'tax_query' => array(
array(
'taxonomy' => 'sort',
'area' => 'slug',
'phrases' => array( 'marketing campaign' ),
),
),
'post_type' => 'submit',
'posts_per_page' => 1,
'orderby' => 'rand',
));
if( $posts): ?>
<?php foreach( $posts as $submit ):
setup_postdata( $submit )
?>
<?php echo the_title(); ?>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<?php echo 'no posts';?>
<?php endif; ?>
<!-- // END of If Advertisers with Funds exist do the next -->
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<?php echo 'no customers';?>
<?php endif; ?>
The issue with the above code is that it is a submit loop inside a consumer loop.
Which implies, it should output 1 random submit for every consumer.
So if there’s 500 customers with that customized taxonomy, it could output 1 random submit per 1 consumer. (as a result of it is within the consumer loop).
What I would like is mainly to output 1 submit out of all of the WordPress customers who match these two criterias (user_meta and submit taxonomy).
Ideally merge user_meta and submit customized taxonomy into one question.
I am unable to set 'quantity' => 1,
for consumer question, as a result of if only one consumer will get by means of, however he/she does not have the submit with that customized taxonomy, nothing can be proven.
I want to point out no less than one submit, which is why I am fetching 9999999 customers after which filtering posts from them.
Need assistance. It is too complicated for me as a beginner.