How to Dynamically Insert x-number of Latest Blog posts in Mailwizz template

nkem123

New Member
Is it possible to dynamically Insert x-number of Latest Blog posts in Mailwizz template? Maybe with a shortcode or anything?

Thanks
 
Is it possible to dynamically Insert x-number of Latest Blog posts in Mailwizz template? Maybe with a shortcode or anything?
Can you give us a brief description of what you mean by this question?
 
@laurentiu / @nkem123 - I think this is what you want ;)
YES. That's exactly what I was looking for. But I will love to limit it to the latest 3 blog posts.

For example, where I saw something like this which inspired me, here is how they did it

IN CASE YOU MISSED IT
1. Latest Blog title 1 goes here (with link)
2. Latest Blog title 2 goes here (with link)
3. Latest Blog title 3 goes here (with link)

How can I do this if you don't mind?
 
How can I do this if you don't mind?
Like is explained in this article: https://www.mailwizz.com/kb/embed-xml-rss-feeds-into-your-campaign/ you can use some options:
urlstring – the url from where we will fetch the feed items. Mandatory.
count – integer – the number of items you want to receive back from the feed. Optional.
Added in 1.5.1:
offsetinteger – the number of items you want to skip loading. Optional.
days-backinteger – the number of days to look back for posts. Optional.
no-item-actionstring – what action to take when no items are found in the feed. Valid values: postpone-campaign(postpones the campaign till next day). Optional.
send-only-unique-items – string – if we should only send unique items. if no items are found, then no-item-action is applied. Valid values: (yes or no). Optional.

YES. That's exactly what I was looking for. But I will love to limit it to the latest 3 blog posts.
In this case you need to use: count – integer – the number of items you want to receive back from the feed. Optional.
 
These things are techy to me. I am still surprised there is no paid plugin on sale for these things. Do you know anyone who has done it that i can copy from? I don't even know where to start
 
Hi MW Team,
could this article be updated according to comments above, please?
I.e. ...
  • the "you will have to enable the feature" is still in there and needs to be removed to avoid confusion
  • I've just tried this with a category feed, which doesn't seem to be working, even through the category feed exists and work on my site. The posts are being picked up by the global feed, just not when pulled via the category feed. Anything I've missed?
This is such a powerful tool, it's worth adding more context.
 
Hello,
I checked and indeed, the first point is valid. I will remove that.
About the second one... Is there any feed example that we can see? We are not aware to handle feed categories anywhere.

Cosmin
 
Hello,
I test your feeds and this what I found. At the end, both https://blim.org.uk/category/jobs/feed/ and https://blim.org.uk/feed are returning the same feed, with a small exception. The one having the category in the url is having part as a title:
Code:
<title>Jobs Archives &raquo; Black Lives in Music</title>

Looks like the html entity &raquo; is making the XML parser to break. In a well formatted xml feed html entities should not appear.
I will take a look with @twisted1919 to see how to handle this situation on our side.

Bottom line, the issue not the category itself, but the RSS feed content

Cosmin
 
Hello,
I test your feeds and this what I found. At the end, both https://blim.org.uk/category/jobs/feed/ and https://blim.org.uk/feed are returning the same feed, with a small exception. The one having the category in the url is having part as a title:
Code:
<title>Jobs Archives &raquo; Black Lives in Music</title>

Looks like the html entity &raquo; is making the XML parser to break. In a well formatted xml feed html entities should not appear.
I will take a look with @twisted1919 to see how to handle this situation on our side.

Bottom line, the issue not the category itself, but the RSS feed content

Cosmin
Thanks, Cosmin.
The difference between the two feeds is that one is ALL posts, and the other is just from that category. That's why they are very similar.

The ASCII in the title tag came from the SEO plugin. I've managed to fix it and it seems to be working now. Thanks for your help.
 
Since all of our clients use WordPress, would you know how the image (post image / thumbnail) could be displayed independently from the content so your example <img src="[XML_FEED_ITEM_IMAGE]" /> can be used?

Right now, the image is part of the [XML_FEED_ITEM_DESCRIPTION] and shows, but would not be able to sit in its own cell within a responsive email layout. If we could all it using the [XML_FEED_ITEM_IMAGE] tag as in your example, it would help massively. Any ideas?
 
Just spent some more time and figured it out. The following code, added to the theme's functions.php, did the trick:
Code:
add_filter( 'rss2_ns', function(){
    echo 'xmlns:media="http://search.yahoo.com/mrss/"';
  });

  // insert the image object into the RSS item (see MB-191)
  add_action('rss2_item', function(){
    global $post;
    if (has_post_thumbnail($post->ID)){
      $thumbnail_ID = get_post_thumbnail_id($post->ID);
      $thumbnail = wp_get_attachment_image_src($thumbnail_ID, 'medium');
      if (is_array($thumbnail)) {
        echo '<media:content medium="image" url="' . $thumbnail[0]
          . '" width="' . $thumbnail[1] . '" height="' . $thumbnail[2] . '" />';
      }
    }
  });

Might be an idea to also add something like this to the Knowledge Base article. Just because WP is popular and it won't pick up the image out of the box.
 
Hi @nadworks could you elaborate more on that?
I tried that code snippet, but without success. I changed the yahoo url to my feed, but didn't work either.
I'm using a plug in to show RSS feed (should I try a particular size, like full, medium or thumbnail?), but I tried without it also and didn't work.

Any help will be greatly appreciated.
 
Hi @nadworks could you elaborate more on that?
I tried that code snippet, but without success. I changed the yahoo url to my feed, but didn't work either.
I'm using a plug in to show RSS feed (should I try a particular size, like full, medium or thumbnail?), but I tried without it also and didn't work.

Any help will be greatly appreciated.

Yes, I also had to add this to my functions.php (please note that this is quite specifically edited for our purposes, a recruitment website, so you'll have to tweak this for the custom fields you want to pull into the content section):

// display featured post thumbnails in RSS feeds add_filter( 'the_content_feed', 'featured_image_in_feed' ); add_filter( 'the_excerpt_rss', 'featured_image_in_feed' ); function featured_image_in_feed( $content ) { global $post, $wp_query; $postid = $wp_query->post->ID; $custom_metadata1 = get_post_meta($postid, 'company', true); $custom_metadata2 = get_post_meta($postid, 'contract_type', true); $custom_metadata3 = get_post_meta($postid, 'career_stage', true); $custom_metadata4 = get_post_meta($postid, 'location', true); if( ! $wp_query->is_comment_feed) { if ( has_post_thumbnail( $post->ID ) ){ if($custom_metadata !== '') { // Display custom field data below content $content = $content."<strong>".$custom_metadata1."</strong><br /><em>".$custom_metadata4."</em>"; } } } return $content; }
 
Hi @nadworks thanks for your reply!
I understand that snippet is for custom tags, categories, posts, right?

My problem is with the main feed, actually. I can't even pull the images without a plug in (which inserts the image inside the description, and as you mentioned, it's very limiting)
 
Back
Top