Kategorien auschließen bei filtern
-
hi,
habe folgendes Problem. Ich habe eine Teamseite (archive-employees.php / CPT) die ich mit isotope.js filtere.
in dem Filter Dropdown gebe ich die Kategorien (Office Wien, Office Berlin, etc) aus. Blöd ist das hier alle Kategorien ausgegeben werden. z.B (unkategorisiert,…) was ich nicht will. Hab schon mehreres versucht komm aber nicht drauf wie ich das fixen kann. Vielleicht kann mir hier jamand helfen.hier mein archive file
<div class="flex flex-wrap"> <div class="lg:w-2/3 pr-8 sm:w-full"> <p><?php _e('Specialists from all around the world form a multicultural team at. As a Destination Management Company we speak your language and know how your customers tick. Our experienced staff members are more than happy to fulfil your customers needs.', 'nothing') ?></p> </div> <div class="lg:w-1/3"> <div class="relative"> <?php $customPostType = 'employees'; $customTax = 'category'; $wp_query = new WP_Query(); $wp_query->query(array( 'post_type'=> $customPostType, 'posts_per_page' => -1, 'paged' => $paged, )); if ($wp_query->have_posts()) : // Create Filter buttons from all Categories that have posts // create an array $filterLinks = array(); // an empty array to add to our previous array $newarray = array(); // Starter "Show All' Array $starter = array('name'=>'show all','slug'=>'*'); // put it into our array $filterLinks[] = $starter; $taxterms = get_terms( $customTax ); // loop through terms if not empty if ( ! empty( $taxterms ) && ! is_wp_error( $taxterms ) ){ foreach ( $taxterms as $taxterm ) { // show all is a little different, so we add a "." to the others $datafilter = '.' . $taxterm->slug; // create some $newarray = array( 'name' => $taxterm->name, 'slug' => $datafilter, ); // load it up $filterLinks[] = $newarray; } } // print_r ($newarray); echo '<div id="filters" class="button-group"><select class="w-full md:w-full border h-10 text-black-link px-2 appearance-none">' ."\n"; foreach ($filterLinks as $links) { echo '<option class="button" data-filter="' . $links['slug'] . '">' . $links['name'] . '</option>'."\n"; } echo '</select></div><!-- isotope filters -->'; ?> <div class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700"> <svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"></path></svg> </div> </div> </div> </div> <div id="container" class="flex flex-wrap -mx-2"> <?php while ($wp_query->have_posts()) : $wp_query->the_post(); // Get the terms with each post $terms = get_the_terms( $post->ID, $customTax ); if ( $terms && ! is_wp_error( $terms ) ) : $cat_links = array(); foreach ( $terms as $term ) { $cat_links[] = $term->slug; } $mycats = join( " ", $cat_links ); endif; ?> <div class="item newsblock w-1/4 p-2 employee <?php echo $mycats; ?>"> <a href="<?php the_permalink(); ?>"> <div class="hover"> <section> <div class="item-img border-secondary hover:bg-secondary"> <?php $team_img = get_the_post_thumbnail_url(); ?> <img src="<?= $team_img; ?>" alt="" class="image" style="width:100%"> <div class="middle"> <div class="team text-right"> <span class="text-xs text-white"><?php the_field('office'); ?></span> </div> <div class="language text-right"> <span class="text-xs text-white"><?php the_field('languages'); ?></span> </div> <span class="text-3xl block text-white"><?= the_field('greetings'); ?></span> <div class="text"> <span class="text-2xl text-right font-bold my-4 block text-white"><?= the_title(); ?></span> </div> <hr class="border border-t-white"> <div class="text-right"> <span class="text-right text-xs text-white"><?= the_field('position'); ?></span> </div> </div> </div> </section> </div> </a> </div> <?php endwhile; ?> </div>
- Das Thema „Kategorien auschließen bei filtern“ ist für neue Antworten geschlossen.