• hamid009

    (@hamid009)


    Hello, I need help is it possible to send Emails every week, basically I have a Job website, I want to send New Jobs of different categories to subscribers of their list, now if I use default Post Notification than style is not particularly suitable for Job types listing and it looks bad, so I have created Custom Shortcode which creates latest Job listings in mailpoet, so how can I send this weekly ? or is this possible that I use Post Notifications but don’t show default posts from mailpoet? how to trigger this Template without adding Default post widget.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Ojoma a11n

    (@geraltrivia)

    Hello there @hamid009 ,

    Thank you for reaching out to us.

    If your new jobs are in different categories, you can use MailPoet’s post notifications to include or exclude specific categories for your emails.

    You mentioned a custom shortcode—does this display in the MailPoet editor or is it applied to a page or post? Could you walk us through how you created it? Post notifications are triggered by new posts in categories recognized by MailPoet, so your shortcode solution might work if it triggers a post notification.

    Thread Starter hamid009

    (@hamid009)

    so this is my setup, I have Jobs Custom Post Type, with 20 Categories, and I already created 20 Lists and added them to Subscribe link of each job form, so if someone fill mailpoet form on Job of IT category so Mailpoet will add them to IT List, now what I did I created custom shortcode using funcitons.php file,

    I want to send latest 6 jobs from category to same list if new job is posted on that category, (how can I get the last sent date of mailpoet in that category so I can only send limited new jobs in case there is only 2 or 3 new jobs in that category, I haven’t explore that part, may be your developer can shed light on this part and give me some hooks etc).

    Anyways this is how I am creating custom shortcode which I then add into Mailpoet email body as [custom:latest_posts "my-job-category"] and it shows latest 6 jobs from my-job- category,when emails are sent.

    function mailpoet_custom_shortcode($shortcode, $newsletter, $subscriber, $queue, $newsletter_body, $arguments) {
    preg_match('/[custom:latest_posts\s+("[^"]+")?]/', $shortcode, $matches);

    $category_slug = ''; 

    if (!empty($matches[1])) {
    $category_slug = trim($matches[1], '"');
    }

    $args = array(
    'posts_per_page' => 6,
    'post_type' => 'job_listing',
    'post_status' => 'publish',
    'tax_query' => array(
    array (
    'taxonomy' => 'job_listing_category',
    'field' => 'slug',
    'terms' => $category_slug,
    )
    ),
    'orderby' => 'date',
    'order' => 'DESC',
    );

    $latest_posts = new WP_Query($args);

    Now problem is that I am querying and showing these jobs in my own template, so I don’t need Latest Post widget to show posts in email body, but somehow only trigger this when there is new jobs in that category.

    Okay I didn’t find solution but I did trick, I added the Latest Post Widget, and change Post to 1, then changed link color to white which is my background color, and changed all other links on pages to different colors manually, now when some new jobs are posted in category it does trigger email.
    but is there a neat way to do this ?

    also can you tell me if there is a way to add some check in WP_Query to only send jobs which are posted after last mailpoet email ?

    Plugin Author Jan Lysy

    (@lysyjan87)

    Hello there?@hamid009?,

    Thanks for sharing more information about the problem.

    how can I get the last sent date of mailpoet in that category so I can only send limited new jobs in case there is only 2 or 3 new jobs in that category, I haven’t explore that part, may be your developer can shed light on this part and give me some hooks etc

    I’m afraid that the MailPoet plugin does not currently have a mechanism that could assist you with this specific request related to your custom shortcode. The functionality you’re describing is managed by the Automated Latest Content block, which works in the background.

    Now problem is that I am querying and showing these jobs in my own template, so I don’t need Latest Post widget to show posts in email body, but somehow only trigger this when there is new jobs in that category.

    Okay I didn’t find solution but I did trick, I added the Latest Post Widget, and change Post to 1, then changed link color to white which is my background color, and changed all other links on pages to different colors manually, now when some new jobs are posted in category it does trigger email.
    but is there a neat way to do this ?

    also can you tell me if there is a way to add some check in WP_Query to only send jobs which are posted after last mailpoet email ?

    I really appreciate your creativity in finding a workaround! While I haven’t found a mechanism that directly resolves your challenge, here’s a cleaner approach you might try:

    1. Set up an Automated Latest Content block for your specific custom post type and category. This will automatically handle most of the filtering for you.
    2. Use the mailpoet_rendering_post_process filter, which allows you to modify the content of the email just before it’s sent. You can use this hook to inject custom logic or manipulate the email content. Here is a full list of MailPoet filters and actions.
    3. Apply a regular expression to find the content of the specific post. MailPoet uses a table with a data attribute like data-post-id to identify posts in the email.
    4. Use the post ID you find to load the specific post, then replace the content as needed with your own prepared content.

    This method has some clear benefits: it allows you to leverage MailPoet’s existing filtering capabilities while reducing the need for manual custom solutions. By relying on the Automated Latest Content block, you avoid the risk of sending duplicate jobs and gain the flexibility to filter posts by category, post type, and more.

    I hope this helps! Let me know if you have any further questions or need clarification.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.