Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8844275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:26:44+00:00 2026-06-14T11:26:44+00:00

I have create a custom post type for FAQs and Custom taxonomies to organize

  • 0

I have create a custom post type for FAQs and Custom taxonomies to organize the Question & Answers.

Also I have create a single page template to display my FAQs by using the code that following

$terms = get_terms(
    'faq_categories',
    array(
        'orderby'   =>  'name',
        'order'     =>  'ASC'
    )
);

foreach($terms as $term)
{
    ?>
    <h3><?php echo $term->name; ?></h3>
    <?php

    $q_args = array(
        'post_type'         =>  'faq',
        'tax_query'         =>  array(
            'taxonomy'  =>  'faq_categories',
            'field'     =>  'slug',
            'terms'     =>  $term->slug
        ),
        'posts_per_page'    =>  -1
    );

    wp_reset_postdata();
    wp_reset_query();

    $ans    =   new WP_Query($q_args);

    while($ans->have_posts())
    {
        $ans->the_post();

        ?>
        <h5><?php echo the_title(); ?></h5>
        <?php
    }
}

My problem is that while I get the question titles, the questions are not grouped by FAQ Categories and under each Category I get all the available questions in repeat.

The result looks like:

Sale [FAQ Category]
    How to buy? [FAQ Question]
    What is the cost? [FAQ Question]
    How can I contact you? [FAQ Question]
    What is your address? [FAQ Question]
Contacts [FAQ Category]
    How to buy? [FAQ Question]
    What is the cost? [FAQ Question]
    How can I contact you? [FAQ Question]
    What is your address? [FAQ Question]

Also I have try with wp_reset_postdate() and wp_reset_query() before and after the WP_Query loop, and I have try to remove them too with no luck.

Any idea on how to solve that issue?

Kind regards
Merianos Nikos

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:26:46+00:00Added an answer on June 14, 2026 at 11:26 am

    tax_query accepts an array of arrays.

    $q_args = array(
        'post_type'         =>  'faq',
        'tax_query'         =>  array(
            array(
                'taxonomy'  =>  'faq_categories',
                'field'     =>  'slug',
                'terms'     =>  $term->slug
            )
        ),
        'posts_per_page'    =>  -1
    );
    

    Or rewrite your query, you don’t really need a tax_query:

    $ans = new WP_Query("post_type=faq&faq_categories=$term->slug&posts_per_page=-1");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom post type named People. I have created a page
i have created a custom post type named Books & i have a widget
I'm currently studying WordPress and want to create a custom Post Type and have
I have created a wordpress custom post type. I am using custom field template
I'm using Custom Post Template which I linked to Magic Fields to create custom
I have a custom post type of Products in my WordPress project. The CPT
Basically I have a custom post type setup called Parts with over 5,000 posts
I have created custom post type 'portfolio' in my web-site. I am able to
I know how to create a custom template for a specific page. However I
I have created a custom post type - Testimonials - for a WP site

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.