Title: Filter Hook for Custom Shortcodes
Last modified: November 5, 2016

---

# Filter Hook for Custom Shortcodes

 *  Resolved [jasnon](https://wordpress.org/support/users/jasnon/)
 * (@jasnon)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/filter-hook-for-custom-shortcodes/)
 * Love the new version so far, great job guys!
 * I’m having issues getting custom shortcodes to work within my newsletters. I’ve
   followed the instructions on this page but it doesn’t seem to be working.
 * [http://docs.mailpoet.com/article/63-hook-to-add-your-own-shortcode](http://docs.mailpoet.com/article/63-hook-to-add-your-own-shortcode)
 * Not sure if this method is outdated now in version 3, but if so can you please
   help explain how to do custom shortcodes in the new version?
 * Thanks so much for the support.

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

 *  [Wysija](https://wordpress.org/support/users/wysija/)
 * (@wysija)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/filter-hook-for-custom-shortcodes/#post-8398746)
 * Thank you for the feedback!
 * We’ve yet to update our documentation. In the meantime, here is how you would
   add a custom shortcode (e.g., `[custom:shortcode]`) to your newsletter:
 *     ```
       add_filter('mailpoet_newsletter_shortcode', 'custom_shortcode', 10, 5);
       function custom_shortcode($shortcode, $newsletter, $subscriber, $queue, $newsletter_body) {
         if ($shortcode === '[your:shortcode]') {
           return "some content";
         }
       }
       ```
   
 * If you’re adding a link shortcode, make sure that it starts with `[link:...]`
   and then use the following code:
 *     ```
       add_filter('mailpoet_newsletter_shortcode_link', 'custom_shortcode', 10, 4);
       function custom_link($shortcode, $newsletter, $subscriber, $queue) {
         if ($shortcode === '[link:some_link]') {
           return "http://example.com";
         }
       }
       ```
   
 * We hope this helps!
    -  This reply was modified 9 years, 6 months ago by [Wysija](https://wordpress.org/support/users/wysija/).
    -  This reply was modified 9 years, 6 months ago by [Wysija](https://wordpress.org/support/users/wysija/).
 *  Thread Starter [jasnon](https://wordpress.org/support/users/jasnon/)
 * (@jasnon)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/filter-hook-for-custom-shortcodes/#post-8399494)
 * Worked perfect thanks so much for the quick response!
 *  Plugin Author [MailPoet](https://wordpress.org/support/users/mailpoet/)
 * (@mailpoet)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/filter-hook-for-custom-shortcodes/#post-8403384)
 * Here’s a dedicated KB article for that: [http://docs.mailpoet.com/article/160-create-your-own-custom-shortcode](http://docs.mailpoet.com/article/160-create-your-own-custom-shortcode)
 *  [Brian Hogg](https://wordpress.org/support/users/brianhogg/)
 * (@brianhogg)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-custom-shortcodes/#post-8561150)
 * Looking at the MailPoet code, I believe to avoid conflicts with other plugins,
   the example code should return `$shortcode` if its not a match? ie.
 *     ```
       add_filter( 'mailpoet_newsletter_shortcode', 'custom_shortcode', 10, 5 );
       function custom_shortcode( $shortcode, $newsletter, $subscriber, $queue, $newsletter_body ) {
         if ($shortcode === '[your:shortcode]') {
           return "some content";
         }
         return $shortcode;
       }
       ```
   
 * Otherwise the second call to that filter will have `$shortcode` as null and never
   match.
 *  [Wysija](https://wordpress.org/support/users/wysija/)
 * (@wysija)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-custom-shortcodes/#post-8561933)
 * [@brianhogg](https://wordpress.org/support/users/brianhogg/) good catch, thank
   you!
 * The updated KB article: [http://beta.docs.mailpoet.com/article/160-create-your-own-custom-shortcode](http://beta.docs.mailpoet.com/article/160-create-your-own-custom-shortcode)
    -  This reply was modified 9 years, 5 months ago by [Wysija](https://wordpress.org/support/users/wysija/).
 *  [Brian Hogg](https://wordpress.org/support/users/brianhogg/)
 * (@brianhogg)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-custom-shortcodes/#post-8562020)
 * No problem!
 * The second link code example may also need return $shotcode; vs just return;
 *  [Wysija](https://wordpress.org/support/users/wysija/)
 * (@wysija)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-custom-shortcodes/#post-8562026)
 * Done! Thanks again.

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

The topic ‘Filter Hook for Custom Shortcodes’ is closed to new replies.

 * ![](https://ps.w.org/mailpoet/assets/icon-256x256.png?rev=3284564)
 * [MailPoet - Newsletters, Email Marketing, and Automation](https://wordpress.org/plugins/mailpoet/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailpoet/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailpoet/)
 * [Active Topics](https://wordpress.org/support/plugin/mailpoet/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailpoet/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailpoet/reviews/)

 * 7 replies
 * 4 participants
 * Last reply from: [Wysija](https://wordpress.org/support/users/wysija/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/filter-hook-for-custom-shortcodes/#post-8562026)
 * Status: resolved