Feedzy RSS Feeds Hooks

WordPress plugins can be very customizable and in this tutorial, we will show you how to change certain features like adding a read more link or displaying items in a random order.

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 (the 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 a link, but keeps 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;
}<br>

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

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

Add a read more link

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

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( '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) 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( '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);<br>

Display item if it 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 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 )
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.