php - Wordpress add post using front end with different title -
i want create system insert wordpress post front-end logged user. have checked same title post many times added different user. how add error message
if post title exist
here code
$u_id = get_current_user_id(); $my_post = array( 'post_title' => 'title', 'post_content' => 'this post content', 'post_status' => 'publish', 'post_author' => $u_id, 'post_type' => 'customer_post', ); $post_id = wp_insert_post( $my_post );
you can prevent checking condition. should try this. wrap code within condition, not allow post same title.
if (!get_page_by_title($title, 'object', 'post') ){ //your code goes here. }
Comments
Post a Comment