• Resolved larrygeams

    (@larrygeams)


    I have a custom post type named propertiesand I want to show all the posts’ titles under the dynamic select. So everytime I add a new property, the select box should have that added as well.

    Here’s the argument.

    $args = array(
    ‘post_type’ => ‘properties’,
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => 3,
    );

    I tried below code but its not working
    wpcf7_dynamic_select post_type=properties

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter larrygeams

    (@larrygeams)

    I think I figured it out already.

    function dynamic_select($choices, $args = array()) {

    $args = array(
    ‘post_type’ => ‘properties’,
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => 3,
    );

    $the_query = new WP_Query( $args );

    while ( $the_query->have_posts() ) :
    $the_query->the_post();
    $output[get_the_title()] = get_the_title();
    endwhile;

    return $output;
    }
    add_filter(‘wpcf7_dynamic_select’, ‘dynamic_select’, 10, 2);

    Im trying to rebuild this solution, but I cant get it work. According the example above, how does the tag in cf7 has to look like?

    [dynamicselect wpcf7_dynamic_select]

    This tag stays blank and Ive didnt found any example how the tag should look like.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to use this plugin with Custom Post Type’ is closed to new replies.