Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $categories = get_terms('faq_cat'); ?>
- <ul class="cat-list">
- <li><a class="cat-list_item active" href="#!" data-slug="">All FAQS</a></li>
- <?php foreach($categories as $category) : ?>
- <li>
- <a class="cat-list_item" href="#!" data-slug="<?= $category->slug; ?>">
- <?= $category->name; ?>
- </a>
- </li>
- <?php endforeach; ?>
- </ul>
- <?php
- $cat_terms = array('1821','1820');
- $faqs = new WP_Query([
- 'post_type' => 'faqs',
- 'posts_per_page' => -1,
- 'tax_query' => [
- [
- 'taxonomy' => 'faq_cat',
- 'field' => 'term_id',
- 'terms' => $cat_terms, // example of $termIds = [4,5]
- 'operator' => 'IN'
- ],
- ]
- ]);?>
- <?php if($faqs->have_posts()): ?>
- <ul class="faq-tiles">
- <?php
- while($faqs->have_posts()) : $faqs->the_post();
- include('templates/faq-single.php');
- endwhile;
- ?>
- </ul>
- <?php wp_reset_postdata(); ?>
- <?php endif; ?>
- <script>
- jQuery(document).ready(function($) {
- $('.cat-list_item').on('click', function() {
- $('.cat-list_item').removeClass('active');
- $(this).addClass('active');
- $.ajax({
- type: 'POST',
- url: 'https://www.pureenergygo.com/wp-admin/admin-ajax.php',
- dataType: 'html',
- data: {
- action: 'filter_faqs',
- category: $(this).data('slug'),
- },
- success: function(res) {
- $('.faq-tiles').html(res);
- }
- })
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement