Skip Navigation

[Resolved] PROBLEM WITH SELECT FIELD DISPLAY

This support ticket is created 5 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by mariaA-6 5 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#921279

My website has two custom post types, Buildings and Architects. Some buildings need to display only one architect in charge, some others 2-5.
I created for now two select fields inside Buildings, named Architect 01 and Architect 02 in order to be able to display accordingly 1 or 2 different architects using the following code:

//dynamically populate select field from Types
add_filter( 'wpt_field_options', 'prefix_custom_options', 10, 3);
 
function prefix_custom_options( $options, $title, $type ){
    switch( $title ){
        case 'Architect 01':
            $options = array();
            $args = array(
                'post_type' => 'architects',
                'orderby' => 'title',
                'order'  => 'ASC',
		'posts_per_page' => -1,);
		case 'Architect 02':
            $options = array();
            $args = array(
                'post_type' => 'architects',
                'orderby' => 'title',
                'order'  => 'ASC',
		'posts_per_page' => -1,);
            $posts_array = get_posts( $args );
            foreach ($posts_array as $post) {
                $options[] = array(
					'#default' => '',
					'#value' => $i++,
                    '#title' => $post->post_title,
                );
            }
            break;
    }
    return $options;
}

I have two very serious problems.
1. I do not have a not set value on either of the select fields. So, even when I only select an architect 01, I always also get the first option of drop down list of architect 02,
2. On my template of buildings in order to display the options I used this>

<a href="[wpv-post-url id="$architects"]">[types field='architect-01'][/types]</a> | <a href="[wpv-post-url id="$architects"]">[types field='architect-02'][/types]</a>

But the link of selected option architect 02 is the link of selected option architect 02 and not the link of the value.

How do I resolve these?

#921560

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - We had issue with the wpt_field_options filter lately but recently its fixed.

Could you please make sure you are using latest Toolset plugins?

Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

#921700

Thanks I resolved my problem by using many to many relationships.

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.