ozh-tweet-archiver
ozh-tweet-archiver copied to clipboard
Assigning post format is broken
Hi! Great plugin, but the feature to automatically assign a post format to imported tweets seems to be broken.
I'm on WP 4.0, Plugin version is 2.0.1.
Parts of my plugin config:
["refresh_interval"]=>
string(4) "3600"
["post_category"]=>
string(1) "1"
["post_format"]=>
string(6) "status"
["post_author"]=>
string(1) "1"
["link_hashtags"]=>
string(2) "no"
["add_hash_as_tags"]=>
string(3) "yes"
["link_usernames"]=>
string(2) "no"
["embed_images"]=>
string(3) "yes"
["un_tco"]=>
string(3) "yes"
Define "broken" please.
@chipbennett what do you think?
In the plugin settings I specified a post format to assign to imported tweets / posts. Import of tweets works, hashtags are converted to tags, too. But the specified post format ("Status", "Aside", "Quote", ... ) is not assigned to the posts. I'm working in a local testing environment, no other plugins activated...
In line 295 of import.php
you assign the post format by adding a property of post_format
to the Array later used by wp_insert_post()
. According to Wordpress Codex this array is a
one-to-one relationship between these elements and the names of columns in the wp_posts table in the database. http://codex.wordpress.org/Function_Reference/wp_insert_post
Since post formats are stored as a builtin taxonomy named post_format
this might cause the issue. A solution could be to set_post_format( $post_id, $format )
after creating the post.
The problem with using set_post_format()
after creating the post is that it will a couple SQL queries per inserted post, which is an awful lot
I have no interest in that feature so I didn't dig further when @chipbennett proposed it in #2 but if done, it has to be done without generating more and more SQL queries
Thanks for getting back. Since post formats are stored in a built in taxonomy adding an additional attribute 'tax_input' => array( 'post_format' => array( $format ) )
to the array passed to wp_insert_post()
should do the trick. No additional function call, probably less SQL queries.