RSS Aggregator by Feedzy Shortcode

Below, you’ll find a detailed guide on how to add the RSS Aggregator by Feedzy Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the RSS Aggregator by Feedzy Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the RSS Aggregator by Feedzy Plugin and the shortcodes it provides:

Plugin Icon
RSS Aggregator by Feedzy – Feed to Post, Autoblogging, News & YouTube Video Feeds Aggregator

"RSS Aggregator by Feedzy is an all-in-one solution for any feed aggregation needs. It supports autoblogging, news, and YouTube video feeds, ensuring fresh content for your site constantly."

★★★★☆ (322) Active Installs: 50000+ Tested with: 6.3.2 PHP Version: 7.2
Included Shortcodes:
  • [feedzy-rss]

RSS Aggregator by Feedzy [feedzy-rss] Shortcode

The feedzy-rss shortcode from the Feedzy RSS Feeds plugin allows users to fetch and display RSS feeds on their WordPress site. It includes options to disable the default style, refresh cache, and offers lazy loading.

Shortcode: [feedzy-rss]

Parameters

Here is a list of all possible feedzy-rss shortcode parameters and attributes:

  • disable_default_style – controls whether to use the default style or not
  • feeds – defines the URLs for the feeds to display
  • refresh – sets the cache refresh rate for the feeds
  • lazy – determines if the feeds are loaded lazily or not
  • gutenberg – indicates if the shortcode is used within Gutenberg editor
  • classname – a custom class name for the feed block

Examples and Usage

Basic Example – A Feedzy RSS Feeds shortcode that fetches and displays feeds from a single URL.

[feedzy-rss feeds="http://example.com/rss" /]

Advanced Examples

Displaying RSS feeds from multiple URLs, with a maximum of 5 items from each feed, and disabling the default style.

[feedzy-rss feeds="http://example1.com/rss, http://example2.com/rss" max="5" disable_default_style="yes" /]

Displaying RSS feeds from a single URL, with the content refreshed every 120 minutes (2 hours), and enabling lazy loading.

[feedzy-rss feeds="http://example.com/rss" refresh="120" lazy="yes" /]

Using the shortcode to display RSS feeds from a single URL, with a custom CSS class for styling, and displaying the full content of each feed item.

[feedzy-rss feeds="http://example.com/rss" classname="my-custom-class" feedData="item_full_content" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [feedzy-rss] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'feedzy-rss', array( self::$instance->admin, 'feedzy_rss' ) );

Shortcode PHP function:

function feedzy_rss( $atts, $content = '' ) {
		$sc                   = $this->get_short_code_attributes( $atts );
		$remove_default_style = isset( $sc['disable_default_style'] ) && in_array( (string) $sc['disable_default_style'], array( '1', 'y', 'yes' ), true );
		if ( ! $remove_default_style ) {
			$settings = apply_filters( 'feedzy_get_settings', array() );
			if ( ! empty( $settings['general']['disable-default-style'] ) ) {
				$remove_default_style = true;
			}
		}
		// Do not enqueue style if the default style settings are enabled.
		if ( ! $remove_default_style ) {
			wp_print_styles( $this->plugin_name );
			// Enqueue style using `wp_enqueue_style` in case `wp_print_styles` not working.
			if ( ! wp_style_is( $this->plugin_name, 'done' ) ) {
				wp_enqueue_style( $this->plugin_name );
			}
			$sc['disable_default_style'] = 'no';
		} else {
			$sc['disable_default_style'] = 'yes';
		}

		$feed_url = $this->normalize_urls( $sc['feeds'] );
		if ( empty( $feed_url ) ) {
			return $content;
		}
		$cache = $sc['refresh'];

		// Disregard the pseudo-shortcode coming from Gutenberg as a lazy one.
		if ( ( true === $sc['lazy'] || 'yes' === $sc['lazy'] ) && ! isset( $sc['gutenberg'] ) ) {
			$attributes = '';
			foreach ( $sc as $key => $val ) {
				// ignore the feedData, its not required.
				if ( 'feedData' === $key ) {
					continue;
				}
				if ( is_array( $val ) ) {
					$val = implode( ',', $val );
				}
				$attributes .= 'data-' . esc_attr( $key ) . '="' . esc_attr( $val ) . '"';
			}
			$lazyload_cache_key = md5( sprintf( 'feedzy-lazy-%s', ( is_array( $feed_url ) ? implode( ',', $feed_url ) : $feed_url ) ) );
			$content            = get_transient( $lazyload_cache_key );

			// the first time the shortcode is being called it will not have any content.
			if ( empty( $content ) ) {
				$content = apply_filters( 'feedzy_lazyload_loading_msg', __( 'Loading', 'feedzy-rss-feeds' ) . '...', $feed_url );
			} else {
				$attributes .= 'data-has_valid_cache="true"';
			}
			$class = array_filter( apply_filters( 'feedzy_add_classes_block', array( $sc['classname'], 'feedzy-' . md5( is_array( $feed_url ) ? implode( ',', $feed_url ) : $feed_url ) ), $sc, null, $feed_url ) );
			$html  = "<div class='feedzy-lazy' $attributes>";
			$html .= "$content</div>";

			wp_register_script( $this->plugin_name . '-lazy', FEEDZY_ABSURL . 'js/feedzy-lazy.js', array( 'jquery' ), $this->version, 'all' );
			wp_enqueue_script( $this->plugin_name . '-lazy' );
			wp_localize_script(
				$this->plugin_name . '-lazy',
				'feedzy',
				array(
					'url'        => get_rest_url( null, 'feedzy/v' . FEEDZY_REST_VERSION . '/lazy/' ),
					'rest_nonce' => wp_create_nonce( 'wp_rest' ),
					'nonce'      => wp_create_nonce( 'feedzy' ),
				)
			);
			return $html;
		}

		if ( isset( $sc['_dry_run_tags_'] ) ) {
			if ( strpos( $sc['_dry_run_tags_'], 'item_full_content' ) !== false ) {
				$sc_clone            = $sc;
				$sc_clone['__jobID'] = ''; // pro expects this but keep it empty.
				$tmp_feed_url        = apply_filters( 'feedzy_import_feed_url', $feed_url, '[#item_full_content]', $sc_clone );
				if ( ! is_wp_error( $tmp_feed_url ) ) {
					$feed_url = $tmp_feed_url;
				}
			}
		}

		$feed = $this->fetch_feed( $feed_url, $cache, $sc );
		if ( is_string( $feed ) ) {
			return $feed;
		}
		$sc      = $this->sanitize_attr( $sc, $feed_url );
		$content = $this->render_content( $sc, $feed, $feed_url, $content );

		return $content;
	}

Code file location:

feedzy-rss-feeds/feedzy-rss-feeds/includes/feedzy-rss-feeds.php

Conclusion

Now that you’ve learned how to embed the RSS Aggregator by Feedzy Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *