• Resolved MelMao

    (@melvinwang44)


    Hi,

    I would want to achieve dynamic posts to show post with one of custom taxonomy. How to achieve that? I’ve read your guide for category only, i tested with my custom taxonomy it doen’t work.

    //Limit custom posts (project) displayed by custom taxonomy (project_status).
    
    function wpf_dynamic_choices_categories( $args, $field, $form_id ) {
        // For field #14 in form #6628, only show entries in project status #5
        if ( '6628' == $form_id && '14' == $field['id'] ) {
            $args['project_status'] = '5';
        } 
        return $args;
    }
    add_filter( 'wpforms_dynamic_choice_post_type_args', 'wpf_dynamic_choices_categories', 10, 3 );

    Could you please help?

    • This topic was modified 3 years, 9 months ago by MelMao.
    • This topic was modified 3 years, 9 months ago by MelMao.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Kenneth Macharia

    (@kmacharia)

    Hi @melvinwang44

    In order to filter posts using a custom taxonomy, I can suggest using the following code instead:

    function wpf_dynamic_choices_project( $args, $field, $form_id ) {
        if ( '6628' == $form_id && '14' == $field['id'] ) {
            $args['tax_query'] = array(
            array(
                'taxonomy' => 'project_status',
                'field'    => 'term_id',
                'terms'    =>  array(5),
            ),
        );
        }
        return $args;
    }
    add_filter( 'wpforms_dynamic_choice_post_type_args', 'wpf_dynamic_choices_project', 10, 3 );
    

    I hope this helps! Thanks. ??

    Plugin Support Kenneth Macharia

    (@kmacharia)

    Hey @melvinwang44

    We haven’t heard back from you in about a week, so I’m going to go ahead and close this thread for now. But if you’d like us to assist further, please feel welcome to continue the conversation (please just see my post above).

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude post from dynamic choices with custom taxonomy’ is closed to new replies.