Skip to content

Instantly share code, notes, and snippets.

@atultiwari
Created November 23, 2017 02:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Add question programmatically in Anspress
$question_array = array(
'post_title' => $question_title,
'post_author' => $user_id_for_question,
'post_content' => $question_content,
'post_type' => 'question',
'post_status' => 'publish',
'comment_status' => 'open'
);
$question_post_id = wp_insert_post($question_array);
if ($question_post_id) {
wp_set_post_terms($question_post_id, $category, 'question_category');
wp_set_post_terms($question_post_id, $tags, 'question_tag');
$answer_permalink = get_permalink($answer_post_id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment