[Resolved] field select taxonomy

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.

Author
Posts
#1610367

I created:
Products
Collections (product taxonomy)
Designer (product taxonomy)

Each collection is made up of one or more products and the designer of the collection is the same as the associated products.

I created the custom fields of the products and collections. Now I wish I could connect the collections with the designers. How can I do? I would like to create a select in the custom Group for Term Fields and insert the taxonomy Designer values. it's possible?
I hope I explained myself
thanks
federico

#1611797

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Federico,

Thank you for contacting us and I'd be happy to assist.

I'm afraid, there is no feature available to make a connection between two taxonomies. However, it is possible to connect two post types through "Post Relationships"
https://toolset.com/documentation/post-relationships/

If you're open to the idea of using custom post types and not the custom taxonomies for the "Collections" and "Designers", you can create one relationship between the "Designers" and the "Collections" posts and the other one between the "Collections" and the "Products" posts.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1614627

I created a custom post designer and a product taxonomy, Collection.
I populated a select with this scritp.

add_filter( 'wpt_field_options', 'populate_select', 10, 3);
function populate_select( $options, $title, $type ){
switch( $title ){
case 'Designer':
$options = array(
);
$args = array(
'post_type' => 'designer',
'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'ASC',
);
$posts_array = get_posts( $args );
foreach ($posts_array as $post) {
$options[] = array(
'#value' => $post->ID,
'#title' => $post->post_title,
);
}
break;
}
return $options;
}

I don't understand why in the insert of the collection the select is populated correctly while in the edit of the category I can't insert any data.

#1617055

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Federico,

Thanks for writing back.

The function to filter "wpt_field_options" seems to be correct, but I'll need to see exactly where it is not working in the admin area.

Can you please share temporary admin login details along with the link to an example page where this is not inserting any data?

Note: Your next reply will be private and though no changes will be made on your website, please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1622481

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Federico,

Thank you for sharing these details and I apologize for the delay in getting back on this.

I've checked the file "single-collezioni.php" and noticed you've used "toolset_get_related_posts" and "toolset_get_related_post" function to get get the related posts.

As explained in the documentation ( https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/ ), the "toolset_get_related_post" function can be used to get a single related post whereas for complex cases or for multiple related posts, "toolset_get_related_posts" function should be used instead.

For example, you can update those lines to:


print_r($course = toolset_get_related_posts( $product, 'prodotto-collezione', 'parent'));
print_r( $facade = toolset_get_related_post( get_the_ID(), 'designer-collezione', 'parent'));

regards,
Waqar