Change 1000+ of WordPress Featured Images in 5 Minutes! › Forums › Questions and Answers › Setting default on posts created programatically
September 20, 2015 at 12:55 am #1836
I’m not sure how or when this plugin adds a featured image, but it’s not working on my site http://rollingmedia.net. I think it may be because I’m creating the posts programatically. I’m using a plugin to create and publish the posts.
Would you expect posts that are created this way (using wp_insert_post) to pick up a featured image using your plugin?
For info, here’s the settings I’m using to try and get it to add featured images in new posts:
Please note that all other features work perfectly; bulk set/replace and image column are great.September 20, 2015 at 2:07 pm #1841
The plugin could work with so-called Autopost plugins if a rule would be based on a category. But those plugins do not give any informations about a category during the insertion of the post. So the rule can not work.September 20, 2015 at 10:51 pm #1847
The plugin adds both categories and tags at the time of insertion. From the code that adds posts:
$my_post = array( 'post_title' => $publish, 'post_content' => $publish, 'post_date' => date("Y-m-d H:i:s",$publish), 'post_status' => 'publish', 'post_author' => 2, 'post_category' => $publish, 'tags_input' => $publish ); $post_id = wp_insert_post($my_post);
So I’m hoping that this should be enough to trigger the attachment of a default image based on these two attributes and the configuration I posted earlier.September 21, 2015 at 12:05 pm #1848
Would you please tell the name of the plugin? I would test it with QFI.September 22, 2015 at 12:36 am #1854
It’s my own plugin that’s not available elsewhere. I was just hoping that yours would work when publishing directly using the standard wp_insert_post api call.
Does your plugin require the post be created in draft then published rather than direct to publish?September 22, 2015 at 8:38 am #1855
QFI does not require a draft status or another status. Every time a post is saved QFI hooks on ‘save_post’. (That hook is fired before the hook ‘wp_insert_post’.) And before that the function ‘wp_set_post_categories()’ is called.
These are called in the function ‘wp_insert_post()’. That function assumed an array with post informations as first parameter. It can consider category informations if values at array key ‘post_category’ are given.
So setting an automatic default featured image based on a category can work with autopost plugins. But I did not find such a plugin which gives category informations to the function ‘wp_insert_post()’. Those plugins are written the way “set the post categories after the insertion of the post”. Fail… Your plugin is a big exception, really!
I would be glad if you would send me your plugin for test purposes. Please mail me at email@example.com.
- You must be logged in to reply to this topic.