0

I am developing a plugin for question & answer.For that i need to create custom post types question & answer.How to link that custom post types so that if i display a post from Question the related answers should be displayed.How to create two custom posts simultaneously when the plugin is activated?

  • 1
    Please change the title, is not in the context with your question. – bueltge Nov 30 '14 at 10:32
  • Look in the AgentPress Listings plugin.php file and class-listings.php file. – Brad Dalton Nov 30 '14 at 10:59
  • ok i will check that. – Anoop Nov 30 '14 at 11:10
  • wordpress.stackexchange.com/questions/22749/… This link is good but how to create two post types simultaneously is not mentioned here.You got any idea – Anoop Nov 30 '14 at 11:28
  • function my_create_post_types() { register_post_type( 'my_post_type', $args); register_post_type( 'my_other_post_type', $args); } add_action( 'init', 'my_create_post_types' ); The first link and this function has to be combined in some way. – Anoop Nov 30 '14 at 12:33
1

WordPress have on default no relationship possibilities for the same objects, like custom post type. But you can create a custom table or use the meta data on each post to create a relationship.

Ready to use

Also it give usable ready solutions:

For a custom solution about meta fields:

You find in this answer helpful hints and the source for a relationshep between the meta data.

  • You have got some custom codes so that i can understand what it is – Anoop Nov 30 '14 at 10:54
  • I have enhanced the answer for more understanding. But I haven't add source, was redundant to a usable answer. – bueltge Nov 30 '14 at 13:36
  • That link was really helpful.Thankyou – Anoop Nov 30 '14 at 14:15
  • The idea is good for adding a field in one post type from other related post type.That is not what iam asking.Suppose we submit an answer for a question,how to relate that question & answer for displaying them correctly.Both questions & answers are seperate cpt.How to display corresponding answers when a question link is clicked.Please check this link shibashake.com/wordpress-theme/add-metabox-custom-post-type – Anoop Dec 13 '14 at 8:45
  • Do you will display the answers to the questions in front end, 2 different CPTs? Or you will display this in a meta box inside the back end on the cpt question? But is not really different. The content inside the meta box or front end have the same loop to get the other CPT with the relationship from CPT "QuestioN" to CPT "Answer". – bueltge Dec 13 '14 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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