question about custom short code
-
Hi,
I would like to use different text strings in my newsletter depending on the total count of posts in the newsletter, i.e. the number that is available in shortcode [newsletter:total].
I have read about creating custom short codes here, and I think this might be the solution. According to this documentation, I have successfully created my own shortcode [custom:subheader] and used it in the email editor. But in order to make it work, I need the php code to assign the value for the total number of posts to my internal varable $count.
Can you please help me with this?
Thank you
So far, my code looks like this, the point where I need help is marked “PLEASE HELP ME HERE”:
add_filter('mailpoet_newsletter_shortcode', 'mailpoet_kahi_shortcode', 10, 6);
function mailpoet_kahi_shortcode($shortcode, $newsletter, $subscriber, $queue, $newsletter_body, $arguments)
{
// always return the shortcode if it doesn't match your own!
if ($shortcode !== '[custom:subheader]') return $shortcode;
$count = 0;
$subheader = "Dies ist eine automatische Benachrichtigung über ";
$count == PLEASE HELP ME HERE
if ($count !== 1)
{
$subheader .= $count;
$subheader .= " neue ";
}
else
{
$subheader .= "einen neuen ";
}
$subheader .= "Artikel ";
return $subheader;
}The page I need help with: [log in to see the link]
You must be logged in to reply to this topic.