Tell us what you are trying to do?
my post type dog , i have a custom field group name Dogs sire , i have an empty select box and which that box to be either automatically populated or if not possible dynamic list that will let me begin typing a name and then be able to select it.
when the name is found and stored ,iwould like to display it as a link that will then show me all dogs related to that name .
i tried following this https://toolset.com/forums/topic/relationships-between-products-product-to-products/#post-1183541
as reccomended by waqar but upon entering thisin my themes function file i just have empty box with a drop down ,i cannot type in the box.
add_filter( 'wpt_field_options', 'func_to_dynamically_populate_dogs_sire', 10, 3);
function func_to_dynamically_populate_dogs_sire( $options, $title, $type ){
switch( $title ){
case 'Dogs Sire':
$options = array();
// add or generate the array of your desired option titles and values
$options[] = array('#value' => '', '#title' => '---',);
break;
}
return $options;
}
i also tried this code too (changed the required to dogs sired)
add_filter( 'wpt_field_options', 'populate_select_1_1', 10, 3);
function populate_select_1_1( $options, $title, $type ){
switch( $title ){
case 'Person 1 Day 1 - Selection':
$options = array();
$args = array(
'post_type' => 'recipe',
'post_status' => 'publish',
'tax_query' => array(
array (
'taxonomy' => 'recipe-category',
'field' => 'slug', // term_id, slug or name
'terms' => 'this-weeks-recipes'
)
)
);
$posts_array = get_posts( $args );
foreach ($posts_array as $post) {
$options[] = array(
'#value' => $post->ID,
'#title' => $post->post_title,
);
}
break;
}
return $options;
}
thank you ever so much, how can i reasine to a different helper? i cant wait until tomorow as i need to complete today!