Setting default on posts created programatically

Change 1000+ of WordPress Featured Images in 5 Minutes! Forums Questions and Answers Setting default on posts created programatically

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1836
    duncanclarke
    Participant

    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:

    Settings

    Please note that all other features work perfectly; bulk set/replace and image column are great.

    #1841
    Martin Stehle
    Moderator

    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.

    #1847
    duncanclarke
    Participant

    The plugin adds both categories and tags at the time of insertion. From the code that adds posts:

    		$my_post = array(
    			'post_title'	=> $publish[0],
    			'post_content'	=> $publish[1],
    			'post_date'		=> date("Y-m-d H:i:s",$publish[2]),
    			'post_status'	=> 'publish',
    			'post_author'	=> 2,
    			'post_category'	=> $publish[3],
    			'tags_input'	=> $publish[4]
    		);
    		$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.

    #1848
    Martin Stehle
    Moderator

    Would you please tell the name of the plugin? I would test it with QFI.

    #1854
    duncanclarke
    Participant

    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?

    #1855
    Martin Stehle
    Moderator

    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 info@quickfeaturedimages.com.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Choose your currency:

Close
Converted prices are for reference only - all orders are charged in € Euros (€) EUR.
  • USDUS Dollars ($)
  • EUREuros (€)
  • GBPPounds Sterling (£)
  • CADCanadian Dollars ($)
  • AUDAustralian Dollars ($)
  • BRLBrazilian Real (R$)
  • INRIndian Rupee (₹)
  • CZKCzech Koruna
  • DKKDanish Krone
  • HKDHong Kong Dollar ($)
  • HUFHungarian Forint
  • ILSIsraeli Shekel (₪)
  • JPYJapanese Yen (¥)
  • MYRMalaysian Ringgits
  • MXNMexican Peso ($)
  • NZDNew Zealand Dollar ($)
  • NOKNorwegian Krone
  • PHPPhilippine Pesos
  • PLNPolish Zloty
  • SGDSingapore Dollar ($)
  • SEKSwedish Krona
  • CHFSwiss Franc
  • TWDTaiwan New Dollars
  • THBThai Baht (฿)
  • TRYTurkish Lira (₺)
  • RUBRussian Rubles