In the Avada Theme there is a page template called 'FAQ page', this 'FAQ Page' can have categories (faq_category_1) and in these categories there can be unlimited questions with answers.

This part of the code (below) gets the categories uncluding the questions/answers, all of them.

What I want to achieve is I only want to show the questions/answers from one specific category that is for example equal to the page title ($title) by using an if statement.

    <?php $portfolio_category = get_terms('faq_category_1');
    <ul class="faq-tabs clearfix">
        <li class="active"><a data-filter="*" href="#"><?php echo __('Alle', 'Avada'); ?></a></li>
        <?php foreach($portfolio_category as $portfolio_cat): ?>
        <li><a data-filter=".<?php echo urldecode($portfolio_cat->slug); ?>" href="#"><?php echo $portfolio_cat->name; ?></a></li>
        <?php endforeach; ?>
    <?php endif; ?>
    <div class="portfolio-wrapper">
        <div class="accordian fusion-accordian">
            <div class="panel-group" id="accordian-one">
                $args = array(
                    'post_type' => 'avada_faq_1',
                    'nopaging' => true
                $gallery = new WP_Query($args);
                $count = 0;
                while($gallery->have_posts()): $gallery->the_post();
                $item_classes = '';
                $item_cats = get_the_terms($post->ID, 'faq_category_1');
                foreach($item_cats as $item_cat) {
                    $item_classes .= urldecode($item_cat->slug) . ' ';

I am a beginning coder (also my first question here:)) and I am not sure where I exaclty need to adjust the code. Thank you!

  • Thank you for the feedback, reading the specific reason I must say I agree, I did not think it through. It is not a specific Wordpress question. I will keep this in mind in the future. :)
    – NXMixin
    Sep 30, 2014 at 17:21

1 Answer 1


There are two things you need to keep in mind. In WordPress you have taxonomies and terms. For instance Category is a taxonomy, and let's say Portfolio is a term belonging to the "Category" taxonomy.

What the code you just posted does is to take all the terms of the "faq_category_1" taxonomy and print all those values as a menu at the top. Then it makes another query to get all the posts of the post type "avada_faq_1" and uses javascript to filter them by term.

If you want to display only the questions of a specific term, you can modify that query:

$args = array(
    'post_type' => 'avada_faq_1',
    'nopaging' => true,
    'tax_query' => array(
            'taxonomy' => 'my_taxonomy', // Could be "faq_category_1" or a custom taxonomy
            'terms' => $title,
            'field' => 'slug'

You can only select terms by either ID or slug, so $title should be converted to slug before making the query, you can do this by using sanitize_title.

Remember that after you change the query the javascript filtering would be pretty much pointless, so you should remove the terms menu at the top.


Not the answer you're looking for? Browse other questions tagged or ask your own question.