wernerB
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é |
---|---|---|---|---|---|
Toolset and Appmysite
Commencé par : wernerB in: Toolset Professional Support |
2 | 4 | Il y a 3 années | ||
push notification
Commencé par : wernerB
in: Toolset Professional Support
Problem: Solution: |
2 | 3 | Il y a 6 années et 1 mois | ||
Beitragsreferenz
Commencé par : wernerB in: Toolset Professioneller Support |
2 | 5 | Il y a 6 années et 2 mois | ||
Only show current User’s posts in post reference field
Commencé par : wernerB
in: Toolset Professional Support
Problem: I have a post reference field that shows all the posts. I would like to filter the options so that only posts by the current logged-in User are shown. Solution: Use this custom code snippet: /* --------------------------------------------- */ // FILTER POST REFERENCE FIELD // Filter the posts in a post reference field by author, where the author is the current User function filter_reference_posts( $query ){ $target_page = 12345; // ID of page with form, or string of page slug $ref_post_type = "cpt-slug"; // slug of post type in the post reference field if ( ( is_page( $target_page ) || ( defined('DOING_AJAX') && DOING_AJAX ) ) && is_array($query->get( 'post_type')) && in_array($ref_post_type, $query->get('post_type')) ) { $current_user = get_current_user_id(); $query->set( 'author', $current_user ); } } add_action( 'pre_get_posts', 'filter_reference_posts' ); |
2 | 3 | Il y a 6 années et 2 mois | ||
Post Form with relation
Commencé par : wernerB in: Toolset Professional Support |
3 | 8 | Il y a 6 années et 2 mois |