Types is a WordPress plugin that lets you easily create custom taxonomies and organize your custom content types in your website.
When you ask for help or report issues, make sure to tell us what you have created so far and what you want to achieve.
Viewing 15 topics - 151 through 165 (of 255 total)
Problem: I am creating an Artist directory and gallery site that provides artists the ability to upload their own artwork images. I have created a Form that allows artists to upload multiple images into a repeating image field. I would like to give artists the ability to apply taxonomy terms to each image in the custom field.
Solution: It is not possible to apply terms to each image uploaded in a repeating custom image field. If you need the ability to add taxonomy terms, you probably need a separate custom post type. Artists can then use Forms to create a new post for each "Artwork", and apply taxonomy terms as needed to that post.
Problem: I have a Form used to create posts. There is a taxonomy field in the Form so Users can choose which term(s) to apply to the new post. I would like to display only terms that were created by the current logged-in User.
Solution: Since WordPress does not natively track the author of each term, you must programmatically add that term author ID in a custom field associated with each term when the term is created. Once that custom field value is added successfully, you can then use the get_terms hook to filter the terms available in the taxonomy field options. Here is an example of the code:
// RESTRICT TAXONOMY TERM FIELD OPTIONS TO USER'S OWN TERMS BY TERM FIELD VALUE
// https://toolset.com/forums/topic/show-only-terms-created-by-current-user-in-taxonomy-dropdown-on-the-form/
function tssupp_terms_by_current_user( $terms, $taxonomies, $args, $term_query ){
$pages = array( 123, 456 ); // comma-separated list of page IDs where this Form is displayed
$taxonomy_slug = 'tax-slug'; // slug of the taxonomy to filter
$author_field_slug = 'field-slug'; // slug of the post author id field
// you should not edit below this line
// loop over each term and get its custom field value
// compare that field value against the current user id and drop any terms with a different value
$user_id = get_current_user_id();
if ( is_page( $pages ) && $taxonomies[0] == $taxonomy_slug ) {
foreach($terms as $key=>$term) {
$term_author = get_term_meta($term->term_id, 'wpcf-' . $author_field_slug, true);
if( $term_author != $user_id ) {
unset( $terms[$key] );
}
}
}
return $terms;
}
add_filter( 'get_terms', 'tssupp_terms_by_current_user',10,4);
Problem: I have built a custom search View in Blocks that displays several taxonomy term checkbox filters. The results include a list of taxonomy term archive links for each post. I would like to include a counter showing the number of posts for each term in both the filters and the results.
Solution:
1. To add the post count to the filter label, adjust the Format in Field Settings for the filter block. Edit this View in the Block Editor and select the taxonomy filter block. Then you will see configurations for Field Settings in the right column. In the Format field, insert the format:
%%NAME%% (%%COUNT%%)
See the attachment filter-format.png for an example.
2. To add the post count to each taxonomy term in the View results, you'll need a bit of code because the Block Editor does not provide similar formatting options for each taxonomy term displayed in a View. You may use a Toolset Fields and Text Block to insert the following code in the HTML tab:
Replace your-taxonomy-slug in this code with the slug of the "Branchen" taxonomy. You can find the slug in Toolset > Taxonomies when you edit the taxonomy. See the attachment fields-and-text-html.png for an example in the Block Editor.