Title: Adding own tags
Last modified: August 21, 2016

---

# Adding own tags

 *  Resolved [MoniqueR](https://wordpress.org/support/users/moniquer/)
 * (@moniquer)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/adding-own-tags/)
 * On the FAQ page there is an example of taking sponsored links as an additinonal
   content. It also states that it can be used to include latest posts. I can not
   get it to work. My goal is to display the most recent posts in a list in the 
   email being send.
    Maybe some-one can help me out?
 * Regards,
    Monique
 * [http://wordpress.org/plugins/wp-better-emails/](http://wordpress.org/plugins/wp-better-emails/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Nicolas Lemoine](https://wordpress.org/support/users/nlemoine/)
 * (@nlemoine)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/adding-own-tags/#post-4514509)
 * Hi Monique,
 * You can add the lastest posts this way :
 *     ```
       add_filter('wpbe_tags', 'add_my_tags');
       function prefix_add_my_tags( $tags ) {
       	if( $latest_posts = prefix_get_posts() )
           	$tags['latest_posts'] = $latest_posts;
           return $tags;
       }
       function prefix_get_posts() {
       	$posts = get_posts();
       	if( empty($posts) )
       		return false;
       	?>
       	<?php foreach($posts as $post) { ?>
       	<div>
       		<h2><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a></h2>
       	</div>
       	<?php }
       }
       ```
   
 * And then add this tag in your template : `%latest_posts%`
 *  [Lisa Sauro](https://wordpress.org/support/users/lisaricochecom/)
 * (@lisaricochecom)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-own-tags/#post-4514545)
 * What file do you past the code?
 *  Thread Starter [MoniqueR](https://wordpress.org/support/users/moniquer/)
 * (@moniquer)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-own-tags/#post-4514546)
 * You have to put the code in your functions.php
 *  [Lisa Sauro](https://wordpress.org/support/users/lisaricochecom/)
 * (@lisaricochecom)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-own-tags/#post-4514554)
 * Thanks so much for your help. I’m using twenty ten theme, tried it but didn’t
   work.
 *  [BBIndikator](https://wordpress.org/support/users/bbindikator/)
 * (@bbindikator)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-own-tags/#post-4514558)
 * Hello,
 * here, too. Insert it as a snippet, but it don´t work. It shows just %latest_posts%
   in a sent E-Mail.
 *  I also have noticed that %blog_description% does not work, if the snippet is
   active.. That means in a sent mail you see %blog_description%, and not the description
   itself..
 * Best regards
 *  [Lisa Sauro](https://wordpress.org/support/users/lisaricochecom/)
 * (@lisaricochecom)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-own-tags/#post-4514560)
 * Hi BBindikator, Did you get latest post to work? Love this plugin and would be
   great if I could add latest post. Right now I have to cut and paste them into
   email for every send.
 *  Plugin Author [Nicolas Lemoine](https://wordpress.org/support/users/nlemoine/)
 * (@nlemoine)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-own-tags/#post-4514563)
 * Hi everyone,
 * There’s a mistake in the piece of code I wrote. The following code has been tested
   and works:
 *     ```
       add_filter('wpbe_tags', 'prefix_add_my_tags');
       function prefix_add_my_tags( $tags ) {
       	if( $latest_posts = prefix_get_posts() )
           	$tags['latest_posts'] = $latest_posts;
           return $tags;
       }
       function prefix_get_posts() {
       	$posts = get_posts();
       	if( empty($posts) )
       		return false;
   
       	ob_start();
       	?>
       	<?php foreach($posts as $post) { ?>
       	<div>
       		<h2><a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a></h2>
       	</div>
       	<?php }
       	return ob_get_clean();
       }
       ```
   
 *  [BBIndikator](https://wordpress.org/support/users/bbindikator/)
 * (@bbindikator)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/adding-own-tags/#post-4514564)
 * That´s it !! : )
 * Thank you very much, it works like a charm!
 * Best regards

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Adding own tags’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-better-emails_f6f6f6.svg)
 * [WP Better Emails](https://wordpress.org/plugins/wp-better-emails/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-better-emails/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-better-emails/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-better-emails/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-better-emails/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-better-emails/reviews/)

## Tags

 * [tags](https://wordpress.org/support/topic-tag/tags/)

 * 8 replies
 * 4 participants
 * Last reply from: [BBIndikator](https://wordpress.org/support/users/bbindikator/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/adding-own-tags/#post-4514564)
 * Status: resolved