Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to create new post with category and tag. #599

Open
vishvajit424 opened this issue Jan 24, 2022 · 2 comments
Open

how to create new post with category and tag. #599

vishvajit424 opened this issue Jan 24, 2022 · 2 comments

Comments

@vishvajit424
Copy link

  • 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:

@bogordesaincom
Copy link

do you was solved this?

@bogordesaincom
Copy link

bogordesaincom commented May 5, 2023

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) );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants