how to create new post with category and tag.
vishvajit424 opened this issue · comments
- Corcel Version: 5.1
- Framework Name & Version: laravel 8
- PHP Version: 7.3.27
- Database Driver & Version: 10.4.18-MariaDB
Description: i m submit a post from a frontend form in wordpress using laravel corcel. but i m getting error Illuminate\Database\QueryException
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'object_id' cannot be null (SQL: insert into wp_term_relationships
(object_id
, term_taxonomy_id
) values (?, 17))
`$post = new Post;
$post->post_title = strip_tags($title);
$post->post_content = $content;
$post->post_status = $post_status;
$post->taxonomies()->sync( array_merge($catsIds, $tagsIds) );
$post->save();`
please i need some help on this
Steps To Reproduce:
do you was solved this?
Maybe you try like this
$post = new Post; $post->post_title = strip_tags($title); $post->post_content = $content; $post->post_status = $post_status; $post->save(); // Place attach taxonomies after save $post->taxonomies()->sync( array_merge($catsIds, $tagsIds) );