Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jean

    (@jeangalea)

    The feed to post add-on lets you do that.
    http://www.wprssaggregator.com/extension/feed-to-post/

    I needed to add some custom fields, we are migrating form feedwordpress to wp-rss-aggregator. The feedwordpress plugin has the ability in the admin to add custom post meta by definig keys and XML path variables for populating the data – very simple.

    To reproduce this i added two filters to the feed-to-post plugin which allow me to 1) add post_exerpt and two to add post_metadata.

    wprss_ftp_converter.php from line 170 now looks like this:

    /*==============================================
    		 * 3) CREATE THE POST
    		 */
    		$post = array(
    			'post_title'		=>	$post_title,
    			'post_content'		=>	$post_content,
    			'post_date'			=>	$post_date,
    			'post_date_gmt'		=>	$post_date_gmt,
    			'post_status'		=>	$post_status,
    			'post_type'			=>	$post_type,
    			'post_author'		=>	$post_author,
    			'tags_input'		=>	implode( ', ' , $post_tags ),
    			'comment_status'	=>	$post_comments
    		);
    
    		$post = apply_filters('wprss_ke_modify_post', $post);
    
    		/*==============================================
    		 * 4) INSERT THE POST
    		 */
    		if ( defined('ICL_SITEPRESS_VERSION') )
    			@include_once( WP_PLUGIN_DIR . '/sitepress-multilingual-cms/inc/wpml-api.php' );
    		if ( defined('ICL_LANGUAGE_CODE') )
    			$_POST['icl_post_language'] = $language_code = ICL_LANGUAGE_CODE;
    
    		// check for multisite option - and switch blogs if necessaray
    		$switch_success = FALSE;
    		if ( WPRSS_FTP_Utils::is_multisite() && $post_site !== '' ) {
    			global $switched;
       			$switch_success = switch_to_blog( $post_site );
    		}
    
    		// Insert the post
    		$inserted_id = wp_insert_post( $post );
    
    		if ( !is_wp_error( $inserted_id ) ) {
    
    			if ( is_object( $inserted_id ) ) {
    				if ( isset( $inserted_id['ID'] ) ) {
    					$inserted_id = $inserted_id['ID'];
    				}
    				elseif ( isset( $inserted_id->ID ) ) {
    					$inserted_id = $inserted_id->ID;
    				}
    			}
    
    			if ( $user === NULL ) {
    				WPRSS_FTP_Utils::log( 'Failed to determine a user for post #$inserted_id', $error_source );
    			}
    
    			// Update the post format
    			set_post_format( $inserted_id, $post_format );
    
    			if ( function_exists( 'wpml_update_translatable_content' ) ) {
    				if ( $post_language === '' || $post_language === NULL ) {
    					$post_language = ICL_LANGUAGE_CODE;
    				}
    				wpml_update_translatable_content( 'post_' . $post_type, $inserted_id, $post_language );
    				/*
    				global $wpdb, $sitepress;
    
    				if ( !is_wp_error( $inserted_id ) && class_exists( 'SitePress' ) ) {
    					$trid = wpml_get_content_trid( 'post_'. $post_type, $inserted_id );
    
    					$wpdb->insert(
    						$wpdb->prefix . 'icl_translations',
    						array(
    							'element_type'			=> 'post_'. $post_type,
    							'element_id' 			=> $inserted_id,
    							'trid'					=> $trid,
    							'language_code'			=> 'en',
    						),
    						array( '%s', '%d', '%d', '%s' )
    					);
    				}*/
    			}
    
    			/*==============================================
    			 * 5) ADD THE POST META DATA
    			 */
    			$thumbnail = '';
    			if ( $enclosure = $item->get_enclosure() ) {
    				$thumbnail = $enclosure->get_thumbnail();
    			}
    
    			$wprss_postmeta = array(
    					'!wprss_item_permalink'		=>	$permalink,
    					'feed_source'				=>	$source,
    					'media:thumbnail'			=>	$thumbnail,
    					'import_date'				=>	time(),
    				);
    
    			WPRSS_FTP_Meta::get_instance()->add_meta(
    				$inserted_id,
    				$wprss_postmeta
    			);
    
    			apply_filters('wprss_ke_add_meta', $item, $inserted_id);
    
    			/*==============================================
    			 * 6) ADD THE TAXONOMY TERMS
    			 */

    Thread Starter robbycornish

    (@robbycornish)

    Thanks Jean. I must have overlooked that extra extension!

    Plugin Author Miguel Muscat

    (@mekku)

    Hi kenaesson,

    We integrated your filters in our code.
    They are now called: wprss_ftp_post_args, wprss_ftp_post_meta, respectively.
    They will be included in the next update, and will be documented on the FAQ on http://wprssaggregator.com/faq

    Thanks for your contribution.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Include original TAGS and my own tag?’ is closed to new replies.