Recent Posts Widget Extended Shortcode

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

Before starting, here is an overview of the Recent Posts Widget Extended Plugin and the shortcodes it provides:

Plugin Icon
Recent Posts Widget Extended

"Recent Posts Widget Extended is a WordPress plugin that enhances your site's functionality by displaying your most recent posts in a dynamic, customizable widget."

★★★★☆ (160) Active Installs: 100000+ Tested with: 6.1.4 PHP Version: 7.2
Included Shortcodes:
  • [rpwe]

Recent Posts Widget Extended [rpwe] Shortcode

The Recent Posts Widget Extended (rpwe) shortcode is used to display recent posts in WordPress. It has parameters to customize the display, such as enabling or disabling the post’s excerpt, thumbnail, date, and more.

Shortcode: [rpwe]

Parameters

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

  • cssid – It sets the CSS ID for the widget.
  • cssID – Alternate way to set the CSS ID for the widget.
  • excerpt – Toggles the display of the post excerpt.
  • thumb – Controls the display of the post thumbnail.
  • date – Sets whether the post date should be displayed.
  • date_relative – Sets whether the date should be displayed relative to the current date.
  • date_modified – Controls the display of the post’s last modification date.
  • readmore – Controls the display of the ‘read more’ link.
  • comment_count – Sets whether the comment count should be displayed.
  • post_title – Controls the display of the post title.
  • link_target – Sets the target attribute for the post links.
  • styles_default – Determines if the default widget styles should be loaded.

Examples and Usage

Basic example – The following shortcode displays the recent posts with default parameters.

[rpwe /]

Advanced examples

Display the recent posts with a specific CSS ID. This can be useful for styling purposes.

[rpwe css_id="my-custom-id" /]

Display the recent posts with the thumbnail, date, and excerpt. The values ‘true’ or ‘false’ can be used to show or hide these elements.

[rpwe thumb="true" date="true" excerpt="true" /]

Display the recent posts with a ‘Read More’ link. This can encourage users to click through to the full post.

[rpwe readmore="true" /]

Display the recent posts with a comment count. This can be useful for showing the level of engagement on your posts.

[rpwe comment_count="true" /]

Customize the link target of the recent posts. This can be useful if you want the links to open in a new tab or window.

[rpwe link_target="_blank" /]

Use the default styles provided by the plugin. Set ‘styles_default’ to ‘false’ if you want to use your own custom styles.

[rpwe styles_default="true" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'rpwe', 'rpwe_shortcode' );

Shortcode PHP function:

function rpwe_shortcode( $atts ) {

	// Breaking changes from version 1.x.x to 2.0.
	if ( isset( $atts['cssid'] ) ) {
		$atts['css_id'] = $atts['cssid'];
	} elseif ( isset( $atts['cssID'] ) ) {
		$atts['css_id'] = $atts['cssID'];
	}

	// Convert string to boolean.
	$attr_strings = array( 'excerpt', 'thumb', 'date', 'date_relative', 'date_modified', 'readmore', 'comment_count', 'post_title', 'link_target', 'styles_default' );
	foreach ( $attr_strings as $attr ) {
		if ( isset( $atts[ $attr ] ) ) {
			$atts[ $attr ] = rpwe_string_to_boolean( $atts[ $attr ] );
		}
	}

	// Merge the default arguments with the shortcode attributes.
	$atts = shortcode_atts( rpwe_get_default_args(), $atts );

	// load default style.
	if ( $atts['styles_default'] ) {
		wp_enqueue_style( 'rpwe-style' );
	}

	return rpwe_get_recent_posts( $atts );
}

Code file location:

recent-posts-widget-extended/recent-posts-widget-extended/includes/shortcode.php

Conclusion

Now that you’ve learned how to embed the Recent Posts Widget Extended 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 *