WordPress.org

Ready to get started?Download WordPress

Forums

FeedWordPress
[resolved] Get the category name from the feedwordpie_item_get_content callback function (2 posts)

  1. umchal
    Member
    Posted 1 year ago #

    Hi,

    This is a great plugin.

    I'm looking for a way to modify fetched post contents based on the category assigned to the feed url by myself in the setting page (not by the category name that the fetched article has).

    As I looked into the code, to modify post contents, I could use the feedwordpie_item_get_content filter. Thanks for using a filter for this.

    Now I have to find a way to retrieve the category name assigned to that feed url. Is there any way to do it?

    http://wordpress.org/extend/plugins/feedwordpress/

  2. umchal
    Member
    Posted 1 year ago #

    The correct filter for modifying the post contents was syndicated_item_content. Amazingly it receives the working object so the categories could be retrieved.

    add_filter(
    	'syndicated_item_content',
    	'syndicated_item_content',
    	10,
    	2
    );
    function syndicated_item_content ($content='', $post='') {
    	$link = $post->link;
    
    	$cats = array();
    	if ('no' != $post->link->setting('add/category', NULL, 'yes')) :
    		$fc = get_option("feedwordpress_syndication_cats");
    		if ($fc) :
    			$cats = array_merge($cats, explode("\n", $fc));
    		endif;
    	endif;
    
    	$fc = $post->link->setting('cats', NULL, array());
    	if (is_array($fc)) :
    		$cats = array_merge($cats, $fc);
    	endif;
    	$post->preset_terms['category'] = $cats;	
    
    	$out = '<pre>' . print_r( $cats, true ). '</pre>';
    	$out .= "<p>" . __FUNCTION__ . "</p>";
    	return $out;
    	// return $content;
    }

    This plugin has a very nice code structure. Appreciate it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic