Skip to content

Instantly share code, notes, and snippets.

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