I have the following query set up
$argsar = array (
'numberposts' => 1,
'post_type' => 'auctionroom',
'meta_key' => 'auctionroom_username',
'compare' => '=',
'value' => $auctionroomname
);
$the_queryar = new WP_Query($argsar);
if ($the_queryar->have_posts()) {
$causercheck = $the_queryar->found_posts;
$the_queryar->the_post();
$auctionroom_id = get_the_ID();
}
It should only return 1 result but it is returning the total number of auctionroom posts when I get
$causercheck = $the_queryar->found_posts;
Having numberposts or not gives the same incorrect total
Thanks in anticipation for any clues
Running Wordpress Version: 5.5.1 with ACF Version: 5.9.1
I have the following query set up
$argsar = array (
'numberposts' => 1,
'post_type' => 'auctionroom',
'meta_key' => 'auctionroom_username',
'compare' => '=',
'value' => $auctionroomname
);
$the_queryar = new WP_Query($argsar);
if ($the_queryar->have_posts()) {
$causercheck = $the_queryar->found_posts;
$the_queryar->the_post();
$auctionroom_id = get_the_ID();
}
It should only return 1 result but it is returning the total number of auctionroom posts when I get
$causercheck = $the_queryar->found_posts;
Having numberposts or not gives the same incorrect total
Thanks in anticipation for any clues
Running Wordpress Version: 5.5.1 with ACF Version: 5.9.1
Share Improve this question asked Oct 10, 2020 at 10:39 Encore ServicesEncore Services 111 bronze badge1 Answer
Reset to default 1It seems that the format I used for $argsar
needs to be changed to
$argsar = array (
'post_type' => 'auctionroom',
'meta_query' => array(
array(
'key' => 'auctionroom_username',
'compare' => '=',
'value' => $auctionroomname
)
)
);
Hope it helps someone