$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>WP Query and multiple queries|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

WP Query and multiple queries

matteradmin10PV0评论

I have a registration form that I'm trying to put limits on sign ups for specific characters. I've added fields for each character with a checkbox. I have this code that I'm working through that's just driving me nuts.. It errors out as I add anything past two queries.. I will say I'm an old guy that does this as a hobby I'm far from a professional. :) and still learning.

$args = apply_filters( 'event_manager_custom_event_registrations_args', array(
'post_type' => 'event_registration',
'post_status' => array_diff( array_merge( array_keys( get_event_registration_statuses() ), array( 'publish' ) ), array( 'archived' ) ),
'ignore_sticky_posts' => 1,
'posts_per_page' => '-1',
'post_parent' => $event_id
) );
//Registration Query
//_registration_limit is a field name
//change the number to your limitation of attendees
$the_query = new WP_Query( $args );
$registration_limit = get_post_meta($event_id,'_darth_vader',true);
if($registration_limit >= 1 && $the_query->found_posts >= $registration_limit ){
return false;
}
return true;
}
$the_query2 = new WP_Query( $args2 );
$registration_limit = get_post_meta($event_id,'_boba_fett',true);
if($registration_limit >= 1 && $the_query2->found_posts >= $registration_limit ){
return false;
}
return true;
}
//Here is where it breaks with a syntax error
$the_query3 = new WP_Query( $args3 );
$registration_limit = get_post_meta($event_id,'_emperor',true);
if($registration_limit >= 1 && $the_query3->found_posts >= $registration_limit ){
return false;
}
return true;
}

Part of me feels like this is an older code that is doing it based on what I can find. Any thoughts or help would be greatly appreciated.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far