Create a gist now

Instantly share code, notes, and snippets.

@versluis /ajax.php
Last active Dec 14, 2015

What would you like to do?
This code adds category posting back into P2
// define $post_cat
$post_cat = $_POST['post_format'];
// and turn it into the category ID
$post_cat = get_category_by_slug( $post_cat );
$post_id = wp_insert_post( array(
'post_author' => $user_id,
'post_title' => $post_title,
'post_content' => $post_content,
'post_type' => 'post',
'tags_input' => $tags,
'post_status' => 'publish',
// bringing back P2 Categories
'post_category' => array( $post_cat -> cat_ID )
// end of mod
) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment