• Resolved frgtech

    (@frgtech)


    I’d like to have a button that links directly to the comment section of the post that is sent in the email. Basically the “Read more” URL with /#respond appended.

    I’ve read the help section on Custom Shortcodes , but not sure how to access the post link to append to.
    ie.. replacing example.com

    add_filter('mailpoet_newsletter_shortcode_link', 'mailpoet_custom_shortcode_respond_link', 10, 4);
    
    function mailpoet_custom_shortcode_respond_link($shortcode, $newsletter, $subscriber, $queue) {
      // always return the shortcode if it doesn't match your own!
      if ($shortcode !== '[link:respond]') return $shortcode;
      
      $respond = '/#respond';
      $respond_link = "<a href='http://example.com{$respond}'>Respond</a>";
      
      return $respond_link;
    }

    Is there an easier way to go about doing this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter frgtech

    (@frgtech)

    Could someone please respond to let me know if this is even possible so I know if I’m on the right track?

    Hi there @frgtech,

    You are on the right track, you’ll need to use get_post_permalink to get the permalink to the post and append that to your respond_link. 🙂

    https://developer.ww.wp.xz.cn/reference/functions/get_post_permalink/

    Thanks!

    Thread Starter frgtech

    (@frgtech)

    Thank you for responding. I’m still fumbling may way around PHP and can’t get this to work but will keep at it. Knowing it’s possible is half the battle.

    Cheers

    Thread Starter frgtech

    (@frgtech)

    I think I’ve given up. I tried all kinds of shortcode including the supplied examples in your custom shortcode tutorial for a custom button and nothing gets expanded.

    I’m wondering if this is because there are options to show more than one post in the post notifications so this shortcode isn’t inside the loop. It would be trivial if we could access the url in the “Read more” text link/button, but we can only modify the text.

    I asked about this in the blog and they said they would submit it as a feature request so I guess I’ll hope to maybe see this in the future. This Call to Action ability is available in other email marketing plugins I’ve used in the past and is a nice easy way to get a user to engage with your site directly. It’s been one of the very few issues I’ve run into with MailPoet.

    • This reply was modified 6 years, 10 months ago by frgtech.
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Button link to #Respond’ is closed to new replies.