WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am coding an exam plugin with following flow:

  1. Subject Categories (custom taxonomy)
  2. Exams (custom post type) related to subject categories (custom taxonomy)
  3. MCQ's (custom post type) related to exam (custom post type)

On Adding New MCQ I need to relate it with exams but exams is a post type not taxonomy. How can it be managed?

share|improve this question
I assume MCQ stands for multiple choice question? – Tom J Nowell Apr 13 '12 at 14:05
yes MCQ stands for multiple choice question – Sidra Sultana Apr 13 '12 at 14:39
up vote 0 down vote accepted

Your data organisation is not perfect, which is why you're faced with the current predicament.

Instead of 2 post types and a taxonomy, use 2 taxonomies and 2 post types

  1. Subject Categories ( taxonomy )
  2. Question Sets ( taxonomy )
  3. Exam ( post type )
  4. MCQ's ( post type )

Assign MCQ's to a question set, and assign exams to both subject categories and question sets.

When in a subject category archive, list exam post types. When in an exam post, list any MCQ's that share the question set of the current post.

This allows you flexibility, such as sharing questions between exams, changing a question that appears in multiple exams once to fix them all, less unnecessary duplication, etc

In single-exam.php:

$terms = get_the_terms( $post->ID, 'question-sets' );

if ( $terms && ! is_wp_error( $terms ) ) :{

    foreach ( $terms as $term ) {
        $q = new WP_Query('post_type' => 'mcq','question-sets' => $term->name);

Where single-mcq.php contains the html for an individual mcq.

share|improve this answer
please explain what will be the 'Question set' in following example: Category-> Database, Exam->Sessional and MCS->What is NF... – Sidra Sultana Apr 13 '12 at 14:38
? Is your comment incomplete? A question set is a grouping of MCQ's, so if I have a maths exam, I have a subject maths, I have an exam post called Maths Exam, I have a question set 'Maths exam questions' and I have MCQ's assigned to that question set – Tom J Nowell Apr 13 '12 at 14:43
got it. thanks alot – Sidra Sultana Apr 13 '12 at 14:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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