martijnH
Fils de soutien créés au cours des 30 derniers jours : 0
Sujets de forum favoris
This user has no favorite topics.
Sujets de forum créés
Status | Sujet | Supporter | Voix | Publications | Nouveauté |
---|---|---|---|---|---|
View with child post type: hide posts where parent is private/concept
Commencé par : martijnH
in: Toolset Professional Support
Problem: I have a View of child posts. I would like to apply a query filter so that the View only shows children of parents that are NOT marked "private". Solution: add_filter('wpv_filter_query', 'ts_parent_not_private_func', 10, 3); function ts_parent_not_private_func($query, $view_settings, $view_id) { $views = array( 16813, 16403 ); // only filter these views if( in_array( $view_id, $views ) ) { $child_ids = array(); // we will push IDs here if the parent is not found, or private $children_args = array( 'post_type' => 'training-datum', 'posts_per_page' => '-1', 'post_status' => 'publish', // you may want to add more filters here to improve the performance of this query ); $children = new WP_Query($children_args); foreach( $children->posts as $child ){ $parent = toolset_get_related_post( $child, 'training_training-datum', 'parent' ); // if there is no parent or the parent is private, push this ID into the exclusion array if( !$parent || get_post_status($parent) == 'private' ){ array_push( $child_ids, $child->ID ); } } $query['post__not_in'] = isset( $query['post__not_in'] ) ? $query['post__not_in'] : array(); $query['post__not_in'] = array_merge($query['post__not_in'], $child_ids ); } return $query; } Relevant Documentation: |
2 | 6 | Il y a 6 années et 1 mois | ||
View with child post type: hide posts where parent is private/concept
Commencé par : martijnH in: Toolset Professional Support |
4 | 7 | Il y a 6 années et 2 mois | ||
Toolset commerce: product depending on userrole
Commencé par : martijnH
in: Toolset Professional Support
Problem: I have a Commerce Form that should add different Products to the User's cart based on their assigned role on the site. One role should receive a free Product, and the other role should receive a paid Product. Solution: In the Form editor, choose the option "Always use the same product regardless of inputs". Select the paid product here to use as the default. Then add this custom code to your child theme's functions.php file: add_filter( 'cred_commerce_add_product_to_cart', 'different_product_by_role', 10, 3 ); function different_product_by_role( $product_id, $form_id, $post_id ) { global $current_user; $user_roles = $current_user->roles; if ( in_array('klant_abonnement', (array) $user_roles) && $form_id == 12345 ) { $product_id = 45678; } return $product_id; } Replace 12345 with the numeric ID of this Commerce Form, and replace 45678 with the numeric ID of the free Product for klant_abonnement Users. Relevant Documentation: |
2 | 3 | Il y a 6 années et 4 mois | ||
wpv-current-user info="role" not always working (depending on db value)
Commencé par : martijnH in: Toolset Professional Support |
2 | 2 | Il y a 6 années et 6 mois | ||
Automate importing content from csv with post relationships
Commencé par : martijnH in: Toolset Professional Support |
2 | 2 | Il y a 6 années et 7 mois | ||
Views is repeating a replace (from another plugin)
Commencé par : martijnH
in: Toolset Professional Support
Problem: I use SEO Smart Links (https://nl.wordpress.org/plugins/seo-automatic-links/), which replaces (on the fly) keywords in a post with a link. In this plugin you attach keywords to internal urls and internal links are created automatically. This is in favor of SEO. Normaly this plugin only replaces one occurance of a keyword (screenshot 1). This number is adjustbale, but I have set it to 1. With Views enabled the replace function is repeated and replaces a second occurance of this keyword (screenshot 2). This is not wanted. When I set the adjustable number too 2, 4 keywords are replaced (instead of 2). How can I make Views not do this? Solution: It seems that filter from "seo-automatic-links" plugin have take effect on the content twice, and I have done below modification in your website: Change the codes from: [wpv-post-body view_template="None"] To: [wpv-post-body view_template="None" suppress_filters="true"] Please test again check if it is fixed or not, Relevant Documentation: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-body suppress_filters (opt): 'true' | 'false' (default) If suppress_filters=’true’, all third party (non WordPress) filters hooked into the_content filter will be removed, when retrieving the post body. |
2 | 8 | Il y a 6 années et 9 mois | ||
Toolset trying to load script in /plugins/types/library/toolset/ > 404
Commencé par : martijnH in: Toolset Professional Support |
2 | 4 | Il y a 7 années et 1 mois |