0

I am trying to implement this: enter image description here The problem is I am not getting the expected output after selecting categories/sub-categories from the dropdown list. I know I have messed up and I don't know what I should do now.

Code to get the dropdown menu having category and subcategory:

<form action="<?php bloginfo('url'); ?>" method="get">
     <div>
     <?php
          $taxonomies = array('categories'); 
             $args = array('orderby'=>'name','hide_empty'=>false);
             $select = get_terms_dropdown_grade_level($taxonomies, $args);
             $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
             echo $select;
        ?>
        <input type="submit" name="submit" value="Select" /> 
     /div>
</form>

`
To get listing after selecting category/sub-category from the drop-down menu

$terms = get_the_terms( $post_id, 'categories' );
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
 
    foreach ( $terms as $term ) {
    
        //View member by group/category
        $listing_members = get_posts(array( 
                'post_type' => 'resources', 
                'posts_per_page' => 20,
                'tax_query' => array(
                array(
                    'taxonomy'         => 'categories',
                    'field'            => 'slug',
                    'include_children' => false,
                    'terms'            => $term->slug,
                

                )
            )
        ));
      
        foreach ( $listing_members as $post ) {
           ?>
            <tr>
             <td><span class="tablesaw-cell-content"><a><?php the_field('name'); ?></a></span></td>
             <td><span class="tablesaw-cell-content"><?php the_field('organization'); ?></span></td>
             <td><span class="tablesaw-cell-content"><a><?php the_field('profile_link'); ?></a></span></td>
             <td><span class="tablesaw-cell-content"><?php the_field('organization_link'); ?></span></td>
             <td><span class="tablesaw-cell-content"><a><?php the_field('contact'); ?></a></span></td>
             <td><span class="tablesaw-cell-content"><?php the_field('notes'); ?></span></td>
            </tr>
        <?php }
    }
} 

  
2
  • What is get_terms_dropdown_grade_level()? What is your expected output? What is the current output? Could you please edit your question with some specifics?
    – Howdy_McGee
    Oct 13, 2020 at 1:14
  • Thank you howdy for taking a look at it. I had to do it via another way.
    – GoonerBruh
    Oct 27, 2020 at 11:58

0

Your Answer

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

Browse other questions tagged or ask your own question.