Hi, a modified version of that snippet, yes. I just tried an unchanged version of your exact snippet and it works ?? – which makes no sense to me.
I’m basically trying to populate a dropdown from 2 CPTs. Its works a treat but just has this strange knock on effect.
My main function code is:
/*
* Add Custom Donation Form Fields
*
* @param $form_id
*/
function give_win_custom_form_fields( $form_id ) {
// Only display for forms with the IDs "754" and "578";
// Remove "If" statement to display on all forms
// For a single form, use this instead:
// One-off Donation Form
if ( $form_id == 211294) {
// $forms = array( 211294 );
//if ( in_array( $form_id, $forms ) ) { ?>
<div id="gift_location-wrap" class="form-row form-row-full">
<label class="give-label" for="gift_location">
Where would you like the gift to be used? <span class="give-required-indicator">*</span>
</label>
<select id="gift_location" name="gift_location" data-required="yes" data-type="select" required="required" tabindex="-1">
<option value="wherever it will help the most" selected="selected">wherever it will help the most</option>
<?php
query_posts(array(
'post_type' => 'countries',
'posts_per_page' =>-1,
'meta_query' => array(
array(
'key' => 'donation_availability',
'value' => '"One-off"',
'compare' => 'LIKE'
))
) );
while (have_posts()) : the_post(); ?>
<option value="<?php the_title(); ?>"><?php the_title(); ?></option>
<?php endwhile;?>
<?php
query_posts(array(
'post_type' => 'appeal',
'posts_per_page' =>-1,
) );
while (have_posts()) : the_post(); ?>
<option value="<?php the_title(); ?>"><?php the_title(); ?></option>
<?php endwhile;?>
</select>
</div>
<?php
// endif;
}
}
add_action( 'give_after_donation_levels', 'give_win_custom_form_fields', 10, 1 );