SendPress Newsletters Shortcode

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

Before starting, here is an overview of the SendPress Newsletters Plugin and the shortcodes it provides:

Plugin Icon
SendPress Newsletters

"SendPress Newsletters is a user-friendly WordPress plugin designed to manage and send your newsletters with ease. It offers customizable templates, detailed reports, and easy scheduling for your convenience."

★★★★✩ (60) Active Installs: 4000+ Tested with: 5.9.8 PHP Version: false
Included Shortcodes:
  • [sendpress-posts]

SendPress Newsletters [sendpress-posts] Shortcode

The SendPress Posts shortcode is a powerful tool for displaying recent posts. It fetches the most recent posts based on the ‘posts’ attribute you set. The shortcode retrieves posts, sorting them by date in descending order. It then creates a return string containing the post title linked to its permalink and the post’s excerpt. The shortcode ends by resetting the query and restoring the original post data, ensuring no conflicts with other parts of your page.

Shortcode: [sendpress-posts]


Here is a list of all possible sendpress-posts shortcode parameters and attributes:

  • posts – controls the number of recent posts displayed
  • content – text displayed as a heading above the posts

Examples and Usage

Basic example – Displaying the most recent post using the SendPress shortcode

[sendpress-posts posts=1]

Here, the ‘posts’ attribute is set to 1, which means it will display the most recent post. The post title will be linked to the full post, and an excerpt of the post will also be displayed.

Advanced examples

Displaying the three most recent posts using the SendPress shortcode

[sendpress-posts posts=3]

In this example, the ‘posts’ attribute is set to 3, which means it will display the three most recent posts. The post titles will be linked to their respective full posts, and an excerpt of each post will also be displayed.

Displaying the five most recent posts with a custom heading using the SendPress shortcode

[sendpress-posts posts=5]Latest News[/sendpress-posts]

This example is a bit more advanced. The ‘posts’ attribute is set to 5, so it will display the five most recent posts. However, this shortcode also includes content between the opening and closing tags. This content will be displayed as a heading above the list of posts. In this case, the heading will be ‘Latest News’.

PHP Function Code

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

Shortcode line:

add_shortcode('sendpress-posts', array('SendPress_Shortcodes','recent_posts_function'));

Shortcode PHP function:

function recent_posts_function($atts, $content = null) {
		global $post;
		$old_post = $post;
      'posts' => 1,
   ), $atts));
      	$return_string = '<h3>'.$content.'</h3>';
	   $return_string .= '<div>';
	   query_posts(array('orderby' => 'date', 'order' => 'DESC' , 'showposts' => $posts));
	   if (have_posts()) :
	      while (have_posts()) : the_post();
	         $return_string .= '<div><a href="'.get_permalink().'">'.get_the_title().'</a></div>';
	          $return_string .= '<div>'.get_the_excerpt().'</div>';
	          $return_string .= '<br>';
	   $return_string .= '</div>';

	   $post = $old_post;
	   return $return_string;

Code file location:



Now that you’ve learned how to embed the SendPress Newsletters 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.


Leave a Reply

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