I'm trying to populate the Child Page dropdown with that of the selected Parent Page - If a specific Parent page is chosen it should fill the second dropdown with all Child pages listed under that parent.

Once the submit button is clicked, it would then direct users to the selected child page.

In the first dropdown, I've pulled the necessary Parent pages based on their page ids. I'm stuck from here. What do I do to achieve getting the secondary dropdown 100% working?

<div id="pages">
    <h2><?php _e('pages:'); ?></h2>
    <form action="<?php bloginfo('url'); ?>" method="get">

        <!-- Parent Page dropdown -->
        <?php wp_dropdown_pages( array(
          'include' => array( 119, 467, 857, 1027, 404 ), // Array of Parent Page IDs to include.
        ) ); ?>

        <!-- Child Page dropdown -->
        <?php wp_dropdown_pages( array(
          'include' => array( ), // Array based on selected Parent Page.
        ) ); ?>

    <input type="submit" name="submit" value="view" />


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.