Client Dash Shortcode

Below, you’ll find a detailed guide on how to add the Client Dash 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 Client Dash Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Client Dash Plugin and the shortcodes it provides:

Plugin Icon
Client Dash

"Client Dash is a WordPress plugin designed to simplify and customize the WordPress admin dashboard. It is perfect for developers and administrators seeking a clean, efficient workspace."

★★★★✩ (44) Active Installs: 4000+ Tested with: 6.1.4 PHP Version: 5.3.0
Included Shortcodes:
  • [cd_feed]

Client Dash [cd_feed] Shortcode

The ClientDash shortcode ‘cd_feed’ fetches RSS feed items from a specified URL. It retrieves a set number of items, defaulting to 5 if not specified. If the URL doesn’t exist or an error occurs, it displays an error message. The shortcode is versatile, allowing for customization of the feed count and source URL.

Shortcode: [cd_feed]

Parameters

Here is a list of all possible cd_feed shortcode parameters and attributes:

  • url – Address of the feed to be fetched.
  • count – Number of feed items to display, default is 5.

Examples and Usage

Basic example – The shortcode ‘cd_feed’ is used to fetch and display feed items from a specified URL. The ‘count’ parameter determines the number of feed items to display.

[cd_feed url="http://example.com/rss" count=5 /]

Advanced examples

Using the ‘cd_feed’ shortcode to display ten feed items from the specified URL.

[cd_feed url="http://example.com/rss" count=10 /]

Displaying feed items without specifying the count. By default, it will display five feed items.

[cd_feed url="http://example.com/rss" /]

Using the shortcode without specifying the URL. This will trigger an error as the URL is a required parameter.

[cd_feed count=5 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'cd_feed', array( $this, 'shortcode_feed' ) );

Shortcode PHP function:

                    function shortcode_feed( $atts = array() ) {

		$atts = shortcode_atts( array(
			'url'   => '',
			'count' => '5',
		), $atts, 'cd_feed' );

		if ( ! $atts['url'] ) {

			ob_start();
			include_once CLIENTDASH_DIR . 'core/helper-pages/views/shortcodes/feed-error.php';

			return ob_get_clean();
		}

		// Get the feed items
		$feed = fetch_feed( $atts['url'] );

		// Check for an error if there's no RSS feed
		if ( is_wp_error( $feed ) ) {

			ob_start();
			include_once CLIENTDASH_DIR . 'core/helper-pages/views/shortcodes/feed-error.php';

			return ob_get_clean();
		}

		$feed_items = $feed->get_items( 0, $atts['count'] );

		ob_start();
		include_once CLIENTDASH_DIR . 'core/helper-pages/views/shortcodes/feed.php';

		return ob_get_clean();
	}
                    

Code file location:

client-dash/client-dash/core/helper-pages/class-clientdash-helper-pages.php

Conclusion

Now that you’ve learned how to embed the Client Dash 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 *