How can we help?
If you are looking for support for our PokaTheme, this is the place!
Home › Forums › PokaTheme support › wp_insert_post doesn’t work with reviews
Tagged: insert post, php, post, update
- This topic has 6 replies, 2 voices, and was last updated 6 months, 3 weeks ago by admin.
July 17, 2022 at 1:58 pm #17105
When I try to programmatically insert posts using PokaTheme into the “affiliates” custom post type, the posts show as published, but are not visible on the frontend until after I click “Update” in the editor.
I’ve been researching this for hours and testing various things, but cannot find why they don’t show up.
Here’s the code:
$insert_post_test = array(
‘post_title’ => $article_title,
‘post_content’ => $article_body,
‘post_date’ => $drip_time,
‘post_status’ => ‘publish’,
‘post_type’ => ‘affiliates’,
‘tax_input’ => array(
‘lists’ => array( 198 ),
‘meta_input’ => [
‘pokafield_affiliate_tag’ => ‘Reload Bonus’,
$insert_post = wp_insert_post($insert_post_test);
Inserting a post into the regular “post” post_type works, and even inserting posts into custom types with other themes works.
I even tried searching the PokaTheme files to see what could be causing this, but nothing works.
Am I missing something, or does PokaTheme not trigger something when programmatically adding reviews?
ThanksJuly 17, 2022 at 2:01 pm #17106
I even tried doing something super basic…
Like inserting a post with the post_title as “asdasd” and post_content as “asdasda” without any other strings. It still doesn’t work.
The post simply will not show until I click “Update” in the editor itself, which defeats the purpose of adding posts programmatically.July 19, 2022 at 1:04 pm #17122
There is no limitation from PokaTheme with adding posts with “wp_insert_post”.
Most likely there is something else that is making your post saved as draft. (As I can understand this is your issue, am I right?)July 20, 2022 at 7:06 am #17132
It’s not saved as a draft. It’s published as any other post would be, but it seems something is triggering on the backend of PokaTheme to make the post be updated on the frontend. It displays as a blank post, with no content.
When you click “Update” in the editor, the post looks the exact same. Even the database entry is the exact same. I studied every single element of this for hours, nothing changes the initial insert post code and the “Update” in the editor.
After all the time looking around, I can only assume that something is not triggering on the backend of PokaTheme. Something that triggers when pushing “Update” manually, but not when doing it programmatically.
I also experimented with doing wp_update_post after wp_insert_post, but it still doesn’t work.
I’ve tried this with dozens of other custom post types on dozens of other themes, and it’s only PokaTheme that has this issue.
July 22, 2022 at 9:33 am #17156
- This reply was modified 10 months, 3 weeks ago by Joseph Anderson.
Need to clarify the sentence “When you click Update in the editor, the post looks the exact same.”
What I mean to say is that, the database entry, and all the post details in the editor look the exact same.
The only thing that’s different is there is no content being display on the frontned until you press “Update”.
This should be easily replicable… I’ve tried it on multiple installations, and the result is always the same.July 22, 2022 at 10:12 am #17159
This is very strange, we will make a few tests and we will get back to this.November 16, 2022 at 3:42 pm #17347
Sorry for the late reply.
You can update to v.4.0.4 and the bug should be fixed now.
- You must be logged in to reply to this topic.