In Feedzy how do I...

Here are some of the hooks you can use with the Feedzy plugin. Note that some of these customizations may require you to have the premium version of the plugin. To see the list of hooks and filters available for this plugin, click HERE

Note: To apply these customizations, please see the details below.

  • Paste the below code snippets into the custom plugin created using the instructions here.
  • You can view more details about each hook mentioned here on this page

This code works only for the imported posts

function new_excerpt_more($more) {
   $current_post_id = get_the_ID();
   $current_post_meta = get_post_meta($current_post_id);

   if (isset($current_post_meta['feedzy_item_url'][0])) {
      return ' <a href="' . $current_post_meta['feedzy_item_url'][0] . '">Read More</a>';
   }
   return $more;
}
add_filter('excerpt_more', 'new_excerpt_more');

Reverse the order of the items displayed

function feedzy_feed_items_reverse( $items, $feedURL ){
    $items = array_reverse($items);
    return $items;
}
add_filter('feedzy_feed_items', 'feedzy_feed_items_reverse', 9, 2)

Remove the first item of the items displayed

function feedzy_feed_items_remove_first( $items, $feedURL ){
    unset($items[0]);
    return $items;
}
add_filter('feedzy_feed_items', 'feedzy_feed_items_remove_first', 9, 2);

Display the title of the website from which the article comes from

  • add the name of the source after the name of the author
  • add_filter( 'feedzy_author_name', 'feedzy_author_name', 10, 3 );
    function feedzy_author_name( $authorName, $feedURL, $item ) {
    	$source		= 'asdasdfsaf';
    	if ( strpos( strtolower( $feedURL ), 'huffington' ) !== false ) {
    		$source	= 'Huffington Post';
    	}
    	return $authorName . ' ' . $source;
    }
    

    Decrease the cache to the minimum value supported viz. 1 minute

    add_filter( 'feedzy_get_short_code_attributes_filter', 'feedzy_get_short_code_attributes_filter', 99, 1 );
    function feedzy_get_short_code_attributes_filter( $atts ) {
    $atts['refresh'] = '1_mins';
    return $atts;
    }
    

    Keep HTML in content

    add_filter( 'feedzy_summary_output', 'feedzy_summary_output', 10, 4 );
        function feedzy_summary_output( $contentSummary, $newLink, $feedURL, $item ) {
            return $item->get_content();
        }
    

    Display all feed items sorted by date independently of the source

    add_action( 'feedzy_modify_feed_config', 'feedzy_modify_feed_config', 10, 1 );
        function feedzy_modify_feed_config( $feed ) {
            $feed->enable_order_by_date( false );
        }
    
        add_filter( 'feedzy_feed_items', 'feedzy_feed_items', 10, 2 );
        function feedzy_feed_items( $items, $feedURL ) {
            $array = (array) $items;
            return usort( $array, 'feedzy_sort_items' );
        }
    
        function feedzy_sort_items( $a, $b ) {
            return $a->get_date( 'U' ) < $b->get_date( 'U' ) ? 1 : -1;
        }
    

    Display the name of the website as the source of the feeds

    add_filter( 'feedzy_author_name', 'feedzy_author_name', 10, 3 );
    function feedzy_author_name( $authorName, $feedURL, $item ) {
    	$source		= '/ source';
    	if ( strpos( strtolower( $feedURL ), 'huffington' ) !== false ) {
    		$source	= 'Huffington Post';
    	}
    	return $authorName . ' ' . $source;
    }
    

    Remove the time from the feed's post

    add_filter('feedzy_meta_args', 'feedzy_meta_args', 10, 3);
    		function feedzy_meta_args($metaArgs, $feedURL, $item){
    			unset( $metaArgs['time_format'] );
    			return $metaArgs;
    		}
    

    Add the site name as an element in the feed (instead of author)

    if ( ! function_exists( 'feedzy_author_name' ) ) {
    	add_filter( 'feedzy_author_name', 'feedzy_author_name', 10, 3 );
    	function feedzy_author_name( $authorName, $feedURL, $item ) {
    		// do something from $feedURL to change $authorName.
    		return $authorName;
    	}
    }
    
    if ( ! function_exists( 'feedzy_author_url' ) ) {
    	add_filter( 'feedzy_author_url', 'feedzy_author_url', 10, 3 );
    	function feedzy_author_url( $authorURL, $authorName, $feedURL ) {
    		// $authorURL = false; // if you don't want to show a link.
    		return $authorURL;
    	}
    }
    

    Make the default image always show

    if ( ! function_exists( 'feedzy_thumb_output' ) ) {
    	add_filter('feedzy_thumb_output', 'feedzy_thumb_output', 10, 4 );
    	function feedzy_thumb_output($contentThumb, $feedURL, $sizes, $item){
    		$string		= $item->get_content();
    		$img        = html_entity_decode( $string, ENT_QUOTES, 'UTF-8' );
    		$pattern	= '/<img[^>]+\>/i';
    		preg_match_all( $pattern, $img, $matches );
    		$image		= null;
    		if ( isset( $matches[0] ) ) {
    			foreach ( $matches[0] as $match ) {
    				$pattern1 = '/src=[\'"]?([^\'" >]+)[\'" >]/';
    				$link   = '';
    				preg_match( $pattern1, $match, $link );
    				if ( ! empty( $link ) && isset( $link[1] ) ) {
    					$image = $link[1];
    				}
    				break;
    			}
    		}
    
    		if( ! empty( $image ) ) {
    			$contentThumb	= $image;
    		}
    		return $contentThumb;
    	}
    }
    

    Pull the content from the feed into the post

    add_filter( 'feedzy_content', 'feedzy_content_from_desc' );
    function feedzy_content_from_desc($x){
    return '';
    }
    

    Display full content instead of summary

    add_filter('feedzy_summary_input', function($summary, $content, $url){
    if ( 'http://feedpress.me/thelifeafter' === $url ) {
    return $content;
    }
    return $summary;
    }, 10, 3);
    
    function bweb_feedzy_add_nofollow( $content ) {
    	return str_replace( '<a href', '<a rel="nofollow" href', $content );
    }
    add_filter( 'feedzy_global_output', 'bweb_feedzy_add_nofollow', 10, 1 );
    

    Disable of stripping of all HTML tags

    Note: This might affect all attributes, whether they belong to the title, description or content.

    add_action( 'feedzy_modify_feed_config', 'feedzy_modify_feed_config', 10, 1 );
    function feedzy_modify_feed_config( $feed ) {
    	$feed->strip_attributes(false);
    }
    

    Keep HTML in feed items content

    add_action( 'init', 'feedzy_summary_input_remove', 99 );
    function feedzy_summary_input_remove() {
    	remove_filter('feedzy_summary_input', array( Feedzy_Rss_Feeds::instance()->get_admin(), 'feedzy_summary_input_filter' ), 9);
    }
    

    Change default Feedzy shortcode parameters values

    function bweb_default_feedzy_shortcode( $out, $pairs, $atts ) {
        $out['max'] = '2';
        $out['maxfeed_title'] = 'no';
        $out['thumb'] = 'auto';
        return $out;
    }
    add_filter( 'shortcode_atts_feedzy_default', 'bweb_default_feedzy_shortcode', 10, 3 )
    
    function bweb_feedzy_remove_link_matches( $matches ) {
        return $matches[2];
    }
    function bweb_feedzy_remove_link( $content, $feedURL ) {
        $pattern= '/<a.*href=\"(https?:\/\/.*)\".*>(.*)<\/a>/iU';
        $content= preg_replace_callback( $pattern, 'bweb_feedzy_remove_link_matches', $content );
        return $content;
    }
    

    We’re now going to use this function with the Feedzy hooks

     
    //Remove the thumnail link
    add_filter( 'feedzy_thumb_output', 'bweb_feedzy_remove_link', 9, 2 );
     
    //Remove the title link
    add_filter( 'feedzy_title_output', 'bweb_feedzy_remove_link', 9, 2 );
     
    //Remove the author link
    add_filter( 'feedzy_meta_output', 'bweb_feedzy_remove_link', 9, 2 );
     
    //Or remove all links at once
    add_filter( 'feedzy_global_output', 'bweb_feedzy_remove_link', 9, 2 );
    

    Do not remove HTML tags from the summary and/or use the item content instead of it description

    function bweb_summary_input( $description, $content, $feedURL ) {
        //If you want to use the item content as the description. If not, then remove this line
        //If feed don't have content meta, $content is already equal to $description
        $description = $content;
        
        //List of feeds you don't want to remove HTML tags
        $feedList = array (
            'http://www.gumdust.com/feed',
            'http://b-website.com/feed'
            );
        
        //Remove the item HTML tags (as in the default hook) if not in the above list
        if( !in_array( $feedURL, $feedList ) ) {
            $description = trim( strip_tags( $description ) );
        }
        
        //Remove hellip (as in the default hook) 
        //Keep in mind that it will be added later in the plugin render
        $description = trim( chop( $description, '[&hellip;]' ) );
     
        return $description;
    }
    remove_filter( 'feedzy_summary_input', 'feedzy_summary_input_filter', 9 );
    add_filter( 'feedzy_summary_input', 'bweb_summary_input', 10, 3 );
    

    Remove the end hellip

    function bweb_feedzy_remove_hellip( $content, $feedURL ) {
        $content = str_replace( ' [&hellip;]', '', $content );
        return $content;
    }
    add_filter( 'feedzy_summary_output', 'bweb_feedzy_remove_hellip', 9, 2 );
    
    function bweb_feedzy_readmore( $content, $link, $feedURL ) {
        $content = str_replace( '[&hellip;]', '<a href="' . $link . '" target="_blank">' . __('Read more', 'yourTextDomain') . ' &rarr;</a>', $content );
        return $content;
    }
    add_filter( 'feedzy_summary_output', 'bweb_feedzy_readmore', 9, 3 );
    

    Use your own CSS and dequeue the default plugin CSS style sheet

    You have to put your CSS rules in your own CSS file.

    function bweb_feedzy_remove_style( $content, $feedURL ) {
        global $feedzyStyle;    
        
        //Style is enqueing when this global var is set to TRUE
        $feedzyStyle = FALSE;
     
        return $content;
    }
    add_filter( 'feedzy_global_output', 'bweb_feedzy_remove_style', 9, 2 );
    

    Use inline CSS and dequeue the default plugin CSS style sheet

    function bweb_feedzy_custom_style( $content, $feedURL ) {
        global $feedzyStyle, $feedzyStyleCustom;    
        
        //Prevent enqueing default stylesheet
        $feedzyStyle = FALSE;
     
        //New global var to prevent printing multiple times the inline CSS
        if( !isset( $feedzyStyleCustom ) )
        $feedzyStyleCustom = FALSE;
        
        $customStyle = '
            <style>
                .feedzy-rss .rss_item {
                    border-bottom: 1px solid #eee;
                }
                .feedzy-rss .rss_item .title {
                    font-weight: bold;
                }
                .feedzy-rss .rss_item:after{
                    content:"";
                    display:block;
                    clear: both;
                }
                .feedzy-rss .rss_item .rss_image {
                    float: left;
                    text-decoration: none;
                    border: none;
                }
                .feedzy-rss .rss_item .rss_image span{
                    display:inline-block;
                    background-size: cover;
                    background-position: 50%;
                }
                .feedzy-rss .rss_item .rss_image {
                    margin: 0.3em 1em 0 0;
                }
                .feedzy-rss .rss_item .rss_content small {
                    display: block;
                    font-size: 0.9em;
                    font-style:italic;
                }
            </style>';
            
        if( ! $feedzyStyleCustom )
        $content = $customStyle . $content;
        
        $feedzyStyleCustom = TRUE;
     
        return $content;
    }
    add_filter( 'feedzy_global_output', 'bweb_feedzy_custom_style', 9, 2 );
    

    Display the feed in a horizontal layout (with scrollbar)

    function bweb_horizontal_layout( $content, $feedURL ) {
        return '<div class="feedzy-horizontal">' . $content . '</div>';
    }
    add_filter( 'feedzy_global_output', 'bweb_horizontal_layout', 9, 2 );
    
    .feedzy-horizontal {
        overflow-y: hidden;
        overflow-x: scroll;
        width: 100%;
    }
    .feedzy-horizontal .feedzy-rss {
        display: table;
        border-spacing: 15px 0;
        table-layout: fixed;
        width: 100%;
    }
    .feedzy-horizontal .feedzy-rss .rss_item {
        border-bottom: 1px solid #eee;
        width: 300px;
        display: table-cell;
    }
    

    Change cache lifetime for a specific feed

    function bweb_feedzy_cache_duration( $feedCacheDuration, $feedURL ) {
        if( 'http://b-website.com/feed' == $feedURL )
            return 60*5; //5 minutes
     
        return $feedCacheDuration;
    }
    add_filter( 'wp_feed_cache_transient_lifetime', 'bweb_feedzy_cache_duration', 10, 2 );
    

    Decode item title with HTML Entities

    function bweb_title_html_entity( $content ) {
        return html_entity_decode( $content );
    }
    add_filter( 'feedzy_title_output', 'bweb_title_html_entity', 9 );
    

    Handle meta feed

    By default, the line of meta (name of the author and publication date) is displayed through a list of arguments:
    $metaArgs = array(
        'author' => true,
        'date' => true,
        'date_format' => get_option( 'date_format' ),
        'time_format' => get_option( 'time_format' )
    );
    
    You can change these arguments through feedzy_meta_args hook and only display the author’s name or date, select the date and time format.
    function bweb_feedzy_meta_args($metaArgs, $feedURL){
        if( 'http://b-website.com/feed' == $feedURL ) {
            $metaArgs = array(
                        'author' => false,
                        'date' => true,
                        'date_format' => 'j F Y',
                        'time_format' => 'G \h i'
                    );
        }
        return $metaArgs;
    }
    add_filter('feedzy_meta_args', 'bweb_feedzy_meta_args', 9, 2);
    
    Or simpler if you want to change a single parameter. Here the author’s name is hidden for all feeds.
    function bweb_feedzy_meta_hide_author($metaArgs, $feedURL){
        $metaArgs['author'] = false;
        return $metaArgs;
    }
    add_filter('feedzy_meta_args', 'bweb_feedzy_meta_hide_author', 9, 2);
    

    Display item if the content contains specific keywords

    function bweb_feedzy_feed_item_keywords_content( $continue, $keywords_title, $item, $feedURL ){
        if( 'http://b-website.com/feed' == $feedURL ) {
            $continue = false;
            $keywords_content = array( 'keyword', 'KEYWORD' );
            foreach ( $keywords_content as $keyword ) {
                if ( strpos( $item->get_description(), $keyword ) !== false ) {
                    $continue = true;
                }
            }
        }
        return $continue;
    }
    add_filter('feedzy_item_keyword', 'bweb_feedzy_feed_item_keywords_content', 9, 4);
    

    Display items in a random order

    function feedzy_feed_items_ramdom( $items, $feedURL ){
        if( 'http://b-website.com/feed' == $feedURL ) {
            shuffle ( $items );
        }
        return $items;
    }
    add_filter('feedzy_feed_items', 'feedzy_feed_items_ramdom', 9, 2);
    

    Change thumbsize and aspect ratio

    function bweb_feedzy_thumb_aspect_ratio( $sizes, $feedURL ) {
        $sizes = array( 
            'width' => $sizes['width'] * (16/9), 
            'height' => $sizes['height']
        );
        return $sizes;
    }
    add_filter( 'feedzy_thumb_sizes', 'bweb_feedzy_thumb_aspect_ratio', 10, 2 );
    

    Edit the blacklist image name (to prevent fetching smileys)

    function bweb_feedzy_blacklist_images( $blacklist ) {
        $blacklist[] = 'xxxx';
        return $blacklist;
    }
    add_filter( 'feedzy_feed_blacklist_images', 'bweb_feedzy_blacklist_images' );
    

    Adjust the number of characters to be extracted from every feed

    add_filter( 'feedzy_content', 'feedzy_content', 10, 2);
    function feedzy_content($content, $item){
        return substr($content, 0, 300);
    }
    

    Import content in Excerpt field as well when importing Feed to Post

    This will import the title to the Excerpt field in your post. 

    add_filter('feedzy_insert_post_args', 'feedzy_insert_post_args', 10, 4);
    function feedzy_insert_post_args( $args, $item, $post_title, $post_content ) {
    	// post_excerpt is the first 10 characters of the title
    	return $args['post_excerpt'] = substr( $post_title, 0, 10 );
    }
    

    Change 10 to increase or decrease the content length.

    This will import the post's main content(description) to the Excerpt field in your post. 

    add_filter('feedzy_insert_post_args', 'feedzy_insert_post_args', 10, 4);
    function feedzy_insert_post_args( $args, $item, $post_title, $post_content ) {
    	// post_excerpt is the first 10 characters of the title
    	return $args['post_excerpt'] = substr( $post_content, 0, 10 );
    }
    

    Change author while importing the feeds

    This code will help you to change the author name to another WP user while importing feeds to posts.

    add_filter( 'feedzy_insert_post_args', 'feedzy_insert_post_args', 10, 3 );
    function feedzy_insert_post_args( $args, $item, $post_title ) {
    	$args['post_author'] = 9909; // or whatever the ID of the user is.
    	return $args;
    }
    

    Change import post limit

    This code will help you to change the limit of import posts. In the Feed Import Options, you can select between 10 to 100 but what if you want to import less than 10 posts or more than 100. In this case, you can use the following code.

    function feedzy_items_limit(){
        $feedLimit=array(1,200,400);
        return $feedLimit;
    }
    add_filter('feedzy_items_limit', 'feedzy_items_limit', 9, 1);
    

    In the above code, the numbers inside the array brackets mark the number of parameters the function receives. After adding this code, you will find these parameters under the "How many feed items to process from the feed" dropdown while importing the feed. You can select an option here and proceed further.

    Do not import post if the content is less than 100 characters long

    This code will help you to exclude the posts if they are small:

    add_filter( 'feedzy_insert_post_args', 'feedzy_insert_post_args', 10, 4 );
    function feedzy_insert_post_args( $args, $item, $title, $content ) {
    	// do not insert if content is less than 100 characters long.
    	// empty title and content prevents WP from inserting a post.
    	if ( strlen( $content ) < 100 ) {
    		$args['post_title'] = '';
    		$args['post_content'] = '';
    	}
    	return $args;
    }
    

    Note: When the posts will be imported, the count will remain original but there will be less number of posts imported. 

    Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.