0

I have a custom post type 'report' that is just a title and some content. I want to know if it's possible that when I create a 'report' it creates a discussion post where you'd leave feedback about the 'report'. I'm new to Wordpress dev, and haven't found much info on create two simultaneous post.

I kinda want to do it myself for the learning experience, but if there's a plugin that'd also be cool.

Thanks in advance.

1 Answer 1

0

Yes. It is possible publish_report action triggered whenever a report is published, or if it is edited and the status is changed to publish. You have to done some error hadling.

function create_discussion_post( $ID, $post ) {
    //Write a code to create a discussion post.
}
add_action( 'publish_report', 'create_discussion_post');
3
  • Ok so I found the documentation for publish_'post-type' after a bit of searching, thanks a lot. However I know it might be a bit noobish, but create_discussion_post is that my own custom function or is it something Wordpress? I can't seem to find it.
    – devslow
    Jan 13, 2017 at 6:30
  • Nvm, create_discussion_post is my own function lol
    – devslow
    Jan 13, 2017 at 6:33
  • Sorry again, what does $ID and $post do in this function? Do they already have a value, or do I give it to them?
    – devslow
    Jan 13, 2017 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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