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
- $faqs = new WP_Query([
- 'post_type' => 'faqs',
- 'posts_per_page' => -1,
- 'order_by' => 'date',
- 'order' => 'desc',
- ]);
- ?>
- <?php if($faqs->have_posts()): ?>
- <ul class="project-tiles">
- <?php
- while($faqs->have_posts()) : $faqs->the_post();
- the_title();
- 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: '/wp-admin/admin-ajax.php',
- dataType: 'html',
- data: {
- action: 'filter_projects',
- category: $(this).data('slug'),
- },
- success: function(res) {
- $('.project-tiles').html(res);
- }
- })
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement