[AUTOMATIQUE] Cet article a plus de 5 ans.
Il se peut donc que les informations qu'il fournit ne soient plus totalement exactes.

I transferred the rights of this plugin (in April, 2016). Please, follow the links below to visit the official documentation.

Plugin presentation   Documentation

logo

Since 1.7, FEEDZY RSS Feeds provide some hooks (see Function Reference/apply filters) to let you tweak the plugin for your needs.

Available Hooks

  • filter: feedzy_feed_items
  • filter: feedzy_item_keyword
  • filter: feedzy_thumb_output
  • filter: feedzy_title_output
  • filter: feedzy_meta_args
  • filter: feedzy_meta_output
  • filter: feedzy_summary_input
  • filter: feedzy_summary_output
  • filter: feedzy_global_output
  • filter: feedzy_thumb_sizes
  • filter: feedzy_feed_blacklist_images
  • filter: feedzy_default_image
  • filter: feedzy_default_error
  • filter: shortcode_atts_feedzy_default
  • native filter: wp_feed_cache_transient_lifetime

Note: the $feedURL argument (variable which contains the displayed feed URL) is available for every hooks, but is always optional. Use it for more targeted tweaks.

Examples

Remove links

Here is a simple function which uses REGEX to remove link, but keep the anchor content:

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',
		'https://www.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( ' […]', '', $content );
	return $content;
}
add_filter( 'feedzy_summary_output', 'bweb_feedzy_remove_hellip', 9, 2 );

Add a read more link

function bweb_feedzy_readmore( $content, $link, $feedURL ) {
	$content = str_replace( '[…]', '<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

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 );

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

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( 'https://www.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) are 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( 'https://www.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 it content contains specific keywords

function bweb_feedzy_feed_item_keywords_content( $continue, $keywords_title, $item, $feedURL ){
	if( 'https://www.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( 'https://www.b-website.com/feed' == $feedURL ) {
		shuffle ( $items );
	}
	return $items;
}
add_filter('feedzy_feed_items', 'feedzy_feed_items_ramdom', 9, 2); 

Change thumbs size 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' );

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 );

Questions, Comments or Suggestions? Feel free to ask!

 

Post written byBrice CAPOBIANCO

WordPress addict and self-taught. I love to learn and to create, then to share…
Founder of bweb.
Share this post

Comments are closed.

Show 80 comments

80 comments

  1. Hola!!
    Para empezar, el plugin es genial!

    Ahora la pregunta. Quiero colocar los post en horizontal, pero no se donde tengo que colocar el código que dices. ¿En que archivos coloco el código?

    • Sorry but I don’t speak spanish.
      You have to paste the PHP code within the functions.php file (in your theme) and likewise for the CSS in your style.css
      Best,

  2. Sorry again Brice.

    I’ve fixed the error with the tag that prevented the feed to be validated. Now I’ve added the featured image *inside* the but still can’t get it shown. At this point the image should be fetched, but it doesn’t. The feed url is the same I shared few hours ago. Could you point me in the right direction?

    • Hi Massimo,
      Your feed looks good now. Since the default cache duration is 12h, you just have to wait that time and it will work. Or use the related hook above to change cache duration.
      Best,

    • Great, almost done here! One last step: I’ve noticed that the link to the author name is somehow wrong. The feed come from a wordpress multisite, so the author name should at least point to the blog (ex. www.blogdomain.com/bloggername ) but instead it points to the main blog site (ex www.blogdomain.com). I can’t figure where this link come from, is not in the feed actually, so I guess it must be retrieved from the guid or something. Is there a way to change this behaviour?

    • Unfortunately this is not so easy since this URL isn’t in the feed as you’ve mentioned it.
      I actually use the blog domain to create the URL : github.com/wp-pl…e.php#L221
      If you know how the author URLs are build in your multisite, you can do some PHP/regex and use the feedzy_meta_output hook to achieve what you want.
      Best,

    • actually I get this information somehow. Is in the -link-. So basically I need to play with regex in order to strip the -link- item and get the correct path, and then use feedzy_meta_output hook.

  3. Hi, I would to implement horizontal rss…So I would to know where implement php code? in index.php or function.php of feed plugin?

    • Hi Chris,
      You can use this example : Display item if it content contains specific keywords
      But replace “get_description” by “get_author” and it should work.
      Best,

  4. Brice, I have attached the entire Feedzy shortcode in case I have an incorrect parameter set. Thanks, Leon

    [feedzy-rss feeds=”https://www.google.com/alerts/feeds/07777077227916797885/2382801991529884645″ max=”20″ feed_title=”no” target=”_blank” meta=”yes” summary=”yes” summarylength=”200″ thumb=”auto” size=”150″ ]

    • Hi Leon,
      Since your feed does not contain any image (jpg/png), Feedzy won’t be able to display them.
      There is nothing to do for that. Sorry.
      Best,

  5. Just started building a site using RSS feeds and selected this one as my first plugin. It works exactly as documented and very simple to use. Thank You. I started with a Google Alerts URL Feed and it works as expected but the thumbnails are shown as the FEEDZY image on ‘yes’ or no thumbnails on ‘auto’. Is there a parameter I have not understood or is there a problem using Google RSS Feeds?

  6. I really like the Feedzy RSS Feeds plug in for WordPress. The only part that is a problem is the time that shows up on the website page when we select “Should we display the date of publication and the author name?” (See WisconsinReport.com top-right.) Where does that time zone come from and what do we do to change it? We are Central Time Zone (currently Central Standard Time), but, the published time that comes on the viewable page is always way off. It probably would be a good idea to allow time zone setting to be included in the information when setting up the Feedzy RSS Feed widget. Otherwise, is there something we can do internally to change the time, or eliminate it, if nothing else (as in date and author, but, not time published)?

    • Hi Gary,
      The time is based on the feed date. So the displayed date is the publication date which appears in the feed itself.
      You can only change the date format (the way to display the date), not the time zone.
      Best

  7. Great Plugin thank you!! Had some trouble when the feedzy cache wouldn’t let go of old posts, but i copied your cache-lifetime code into my code snippets, and it worked well.

  8. Great plugin!!

    Couple of weird things.. we’ve updated posts, but the old title won’t stop coming up. Cannot get feedzy to clear the cache and look at the feed again. Have tried putting your cache timeout function into code snippets, giving a refresh time of 60*0.1. Doesn’t work. Is there another way to clear the feedzy cache?

  9. Hi Brice, is there an way to show feeds in 2 columns? I’ve seen some hook but none of them show how to do this.
    Thank in advance for your answer.

  10. Hey there, i installed the plugin, works only when it chops of an rss feed item it gives a &nbs visible on my site. &nbs […]
    What could be the problem, looks like he cant fit the p to maken it &nbsp […]

    Can i edit it in the css?

    • Hey Brice, well the site is still under construction, but as an example: i see it on other sites aswell like the first rss message from this url: weallchangetheworld.com/collectifs/les-incroyables-comestibles I know it has to do with the overuse of spaces in the text. But when a rss-feed exerpt ends with multiple spaces it’s being chopped at &nbs instead of &nbsp

    • Hi Steffen,
      I think that using a function like bweb_feedzy_remove_hellip (see above) to remove &nbs should works.

  11. I love your plugin and just want to add a read more link. I am very new to wordpress and dont understand how hooks work. I have tried to read through the documentation but just cant get it to work. can you give me step by step directions? It seems like this should be simple and I must be missing something.

  12. In fact, that’s not what I was asking. I was asking if FEEDZY is capable of displaying the categories of posts, and if you could filter what is displayed in a FEEDZY feed by category.

    Ou bien, je suppose que j’essaie en français. Je voudrais savoir si c’est possible d’afficher les <> des postes, et si c’est encore possible de n’afficher que des postes avec une certaine valeur de <>.

    Et merci très beaucoup pour le plugin et aussi pour une vite réponse. Thank you so much! (And sorry for my français pas terrible.)

  13. This works so well! And fit a very specific need I had. I’m trying to pull together all the posts in a multisite WP install into a single feed, and this with the multisite feed plugin is just great!

    I have two questions (and am a WordPress and php beginner, although I do have some programming background):

    1) Is it possible to display categories in the aggregate feed? My feeds do include a category tag.

    2) If categories are available to FEEDZY, can I filter by category? i.e. display only posts that have a specific category.

    Thank you so much!

    • Hi,
      I’m not sure to have well understood your request, but you can add an extra parameter to the WordPress feed’s URL to retrieve only specific catagories.
      The RSS feed’s documentation is available in the CODEX.
      Cheers

  14. Hi, I love your plugin but I’d like to have the horizontal layout with 3 posts visible and the others just below (visible with a vertical scrollbar), not beside. Can you help me giving us a code to do this?

    Thank you!

    • You have to do some CSS to achieve this. I’m sorry but I don’t time to work on this for the moment.
      Sorry. Cheers

  15. Hi, nice plugin,

    but I have a doubt, how do I do to NOT display item if it content contains specific keywords?

    thanks in advance,

    Regards,
    Guido

    • Hi,
      You have to use the fonction “Display item if it content contains specific keywords” (see above on this page) and to replace

      if ( strpos( $item->get_description(), $keyword ) !== false ) {

      by

      if ( strpos( $item->get_description(), $keyword ) === false ) {

      Cheers

    • Hey Brice, sorry to disturb you again,
      I managed to get it work, but only if I put only one Keyword, if I put more than one, it still show the feed that doesn’t have all the keywords blocked. Am I doing something wrong?

      this is the code i’m using:

      function bweb_feedzy_feed_item_keywords_content( $continue, $keywords_title, $item, $feedURL ){

      if( ‘http://feeds.feedburner.com/Exame-Economia?format=xml’ == $feedURL ) {

      $continue = false;

      $keywords_content = array( ‘Keyword0’, ‘keyword1’ );

      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);

      if the post don’t have both keywords it isn’t blocked.

      thanks

    • Hi Guido,
      Actually, this function check if the desctiption contains a specific word only, not a couple. You have to do some changes to check if it contains both two words.
      Cheers

  16. Bonjour Brice
    Is there an easy way to reorder the feed items by title (rather than post date?).
    Thanks in advance
    Julie

    • Salut Julie,
      Yes, you can achieve this with the following functions.


      function bweb_feedzy_alphabetical_sort( $a, $b ){
      return strcmp( $a->get_title(), $b->get_title() );
      }

      function bweb_feedzy_items_title_sort( $items, $feedURL ){
      if( 'https://www.b-website.com/feed' == $feedURL ) {
      usort( $items, 'bweb_feedzy_alphabetical_sort' );
      }
      return $items;
      }
      add_filter( 'feedzy_feed_items', 'bweb_feedzy_items_title_sort', 9, 2 );

      Don’t forget to edit the feed’s URL or remove this conditional test.

  17. Hi,
    I found Your plugin so lovely! can I ask You if You think to add a vertical scroll for RSS?
    Thank You very much
    Mirella

    • Mirella,
      To add a vertical scroll to have to do some basic CSS with a fixed height and an overflow-y auto.
      Cheers

  18. Hi Brice,

    I’m adding a plugin filter so ‘rel=”nofollow”‘ is added to the links. What would be the best place to put this filter so it won’t get lost when updating the FEEDZY plugin?

    Thanks, Bob

    • You can add the hook function in your child theme functions.php file. This way, you won’t lose your tweaks after a plugin update.

  19. Could you please specify which images the plugin takes? I tried some of my blogs with featured images and galleries, but it didn’t showed this images. Does it takes only images in content? Or should they somehow be included into RSS with some RSS management plugin?

    I can see on this page it takes thumbs 150px www.b-website.com/wp-co…50×150.jpg, but if I need a larger images, like 300px, where should I specify this, is it possible if on your site default thumbs are 150px?
    Great plugin, thanks!

    • Hi,
      Here is how it works : github.com/wp-pl…s.php#L204
      By defaulf, feedzy uses the “thumbnail” size. In my blog, it is 150x150px as you saw.

      So if you want to specify a custom image size, you have to do this :


      function bweb_feedzy_insert_thumbnail_RSS( $content ) {
      global $post;
      if ( has_post_thumbnail( $post->ID ) ){
      //You can change the image size with any thumbnail size available on the blog you are using this function.
      $content = '' . get_the_post_thumbnail( $post->ID, 'medium' ) . '' . $content;
      }
      return $content;
      }

      //Remove the default function from the filter
      remove_filter( 'the_excerpt_rss', 'feedzy_insert_thumbnail_RSS' );
      remove_filter( 'the_content_feed', 'feedzy_insert_thumbnail_RSS' );

      //Add the new function to the filter
      add_filter( 'the_excerpt_rss', 'bweb_feedzy_insert_thumbnail_RSS' );
      add_filter( 'the_content_feed', 'bweb_feedzy_insert_thumbnail_RSS' );

      That’s Easy 🙂

  20. Somehow the “Trim the title after X characters” are not working properly, it’s trimming after words then characters ??

  21. Hey There, I want to do different default images for different story types from one rss feed. If that is not possible, I can just have 2 rss feeds back to back, and sort by keyword filter of title. However, is there a way to include only posts with for example APPLE, and then on the next RSS feed, EXCLUDE all posts with APPLE in the title to get the rest of them? ( I only know how to INCLUDE items with keyword).

    Thanks,
    Nelly

  22. Five stars* here from Denmark for Feedzy RSS. The example pages of filters & hooks makes this plugin exceptional.

    One last amend if you could show an example of how to link the description as well.

    As default the thumbs and title are linket to outgoing RSS, but I want also link the description and remove the end hellip.

    Thank you again

  23. In XML the first item is MODENANTIQUARIA 2015
    In the feed the first item is EUDISHOW 2015
    I suppose without on the previous plugin version on my page the order was taken (correctly) from the

    • I still not understand. Without the hook I gave you for the random order, food items are displayed by date, exactly as in the XML.

  24. Thanks Brice, but I have a calendar feed contains the event in progressive priority.
    I need to take it without any parser.
    Thank you again

  25. Thank Brice, I didn’t see the “tid” code in the email only the comment – thanks for your help. Great plugin!

  26. I love Feedzy but have an issue where I want to add this tracking code to all Feedzy RSS outgoing links ?tid=FS,IT

    This is because the people we send traffic to via those RSS feeds track links sent by us on other pages with this code with software that picks up the incoming links with that code. How can I alter the plugin code please (or pay you to this) for the Feed, so all outgoing RSS links are appended with this ?tid=FS,IT code please?

    • Hi Mia,
      If you want to add an extra param to every links, you can do something like this :


      function bweb_feedzy_add_link_param_matches( $matches ) {
      return '' . $matches[2] . '';
      }
      function bweb_feedzy_add_link_param( $content, $feedURL ) {
      $pattern= '/(.*)<\/a>/iU';
      $content= preg_replace_callback( $pattern, 'bweb_feedzy_add_link_param_matches', $content );
      return $content;
      }
      add_filter( 'feedzy_global_output', 'bweb_feedzy_add_link_param', 9, 2 );