Skip to content

Instantly share code, notes, and snippets.

@danielbachhuber
Created June 6, 2012 20:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save danielbachhuber/2884507 to your computer and use it in GitHub Desktop.
Change FeedWordPress behavior to reset post_date_gmt to now
<?php
/**
* For the FeedWordPress posts that are published on import, set the
* publication timestamp to now (instead of the datetime in the feed)
*/
add_filter( 'syndicated_item_published', 'fwpx_syndicated_item_published' );
function fwpx_syndicated_item_published( $ts ) {
return time();
}
/**
* Reset FeedWordPress' behavior of setting the post_date_gmt
* Only do this where the guid is different than our existing site and for 'pending' posts
* We want editors to be able to "Publish Immediately", instead of publish at the syndicated post's publication time.
*/
add_filter( 'update_syndicated_feed_completed', 'fwpx_update_syndicated_feed_completed' );
function fwpx_update_syndicated_feed_completed( $import_id ) {
global $wpdb;
// Get all of the syndicated posts that haven't yet been published
$query = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_status='pending' AND guid NOT LIKE %s;", '%' . site_url() . '%' );
$post_ids = $wpdb->get_col( $query );
foreach( $post_ids as $post_id ) {
$wpdb->update( $wpdb->posts, array( 'post_date_gmt' => '0000-00-00 00:00:00' ), array( 'ID' => $post_id ) );
}
};
@junecv
Copy link

junecv commented Jan 26, 2013

Thanks Daniel. I've added this to feedwordpress/posts-page.php (probably very brutal/inelegant act, but) it works for new posts! However, when the posts are syndicated, they turned to "scheduled" again.

Trialing & erring. Appreciate if you may help.

@adnankhairy
Copy link

@JuneChan
Does you fixed this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment