Auto Fill Dropdown – Max Number

Home Forums Quform WordPress Auto Fill Dropdown – Max Number

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #13190
    Brian
    Participant

    Hello,

    I am currently using the following code to autopopulate one of the dropdown boxes on a form that I am using:

    function mytheme_dynamic_checkbox_values($form)
    {
    $options = array();
    $query = new WP_Query(array(‘cat’ => 6));

    while($query->have_posts()) {
    $query->the_post();
    $options[] = array(
    ‘label’ => get_the_title(),
    ‘value’ => get_the_title()
    );
    }

    wp_reset_postdata();

    $checkboxes = $form->getElement(‘iphorm_1_2’);
    if ($checkboxes instanceof iPhorm_Element_Multi) {
    $checkboxes->setOptions($options);
    }
    }
    add_action(‘iphorm_pre_display_1’, ‘mytheme_dynamic_checkbox_values’);

    I am using this to pre-populate the dropdown with a list of all posts under a certain category. The issue is that the dropdown is only generating the most recent 10 posts from the category rather than all of them. How can I update this to include all of the posts rather than just the first 10?

    #13199
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #13205
    Brian
    Participant

    Worked like a charm! Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy