0
votes

Hopefully one of you can help me out.

I have created a custom post type called FAQs, these need to be split up into categories. I created the a custom taxonomy and 3 categories within that. What I’m trying to do is display the posts of a specific category from the custom taxonomy.

The custom post type is avius_faqs The custom taxonomy is faqs_taxonomy The category I'm trying to display is survey-faqs

The code below is what I currently have but instead of displaying posts from a specific taxonomy it is displaying posts from all categories in that taxonomy.

<?php
query_posts( array( 'post_type' => 'avius_faqs', 'faqs_taxonomy' => 'surveys-faqs'));
if (have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div class="faq">
        <i class="fa fa-plus"></i>
        <h3 class="question"><?php the_field('question', false, false); ?></h3>
        <div class="answer"><?php the_field('answer'); ?></div>
    </div>
<?php endwhile; endif; wp_reset_query(); ?>

Hope this all makes sense and any help is greatly appreciated!

Thanks in advance!

1

1 Answers

2
votes

I hope It will work for you.

$query = new WP_Query( array(
        'post_type'=>'avius_faqs',
        'posts_per_page'=>4,
        'tax_query'=>array(
            array(
                'taxonomy'=>'faqs_taxonomy',
                'field'=>'slug',
                'terms'=>'surveys-faqs'  // change to slug according to your requirement
            )
         )
    ) );

    while ( $query->have_posts ) {
        $query->the_post();
    }