Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@versluis
Created June 29, 2012 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save versluis/3016538 to your computer and use it in GitHub Desktop.
Save versluis/3016538 to your computer and use it in GitHub Desktop.
How to bring back Post Categories in P2 v1.4
// 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 )
//
) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment