CMS Development

kevinpotts
参加者

related_blog_posts only shows some posts from blog

Hello everyone. I have been trying to understand why related_blog_posts only returns some blog posts whether using default rendering, callback or post_formatter. Basic code:

 

 

{% related_blog_posts blog_ids="555555555555" callback="news_headlines" limit=3 %}
<script>
  var news_headlines = function(blogposts) {
    var formatted = "<div>";
    for (var i = 0; i < blogposts.length; i++) {
      var blogpost = blogposts[i];
      formatted += '<div class="blog-list only-headlines press-releases">';
      formatted += `<span class="blog-list-date">${new Date(blogpost.publishDate).toLocaleDateString()}</span>`;
      formatted += `<a class="blog-list-title" href="${blogpost.url}">${blogpost.name}</a>`;
      formatted += '</div>';
    }
    formatted += '</div>';
    return formatted;
  }
</script>

 

 

I know this code functions because it renders one post. Unfortunately, it only renders ONE post. Is it possible that there is a delay in the CMS system actually accessing the HubSpot contentdatabase?

 

I ask because the post that is rendering was added a few days ago. The post that won't render was added an hour ago. I double-checked everything and they are functionally identical: same blog, same author, same language, neither have tags, both published within last 30 days, etc. Only the actual content is different.

 

Any ideas?

0 いいね!
6件の返信
kevinpotts
参加者

related_blog_posts only shows some posts from blog

Great tip on the Chrome extension. Thank you.

0 いいね!
Teun
名誉エキスパート | Diamond Partner
名誉エキスパート | Diamond Partner

related_blog_posts only shows some posts from blog

@kevinpotts I've had some issues with related blogs and popular blogs showing up. Most of the time you have to wait a few hours for them to show up.
If it is a cache related issue, make sure to install the HubSpot Developer Extension. It has a bust cache option to make sure you are looking at the most recent version of your page (great when developing). 

P.S. The debug param is pretty handy too.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


kevinpotts
参加者

related_blog_posts only shows some posts from blog

Just to report back in, the script is now working. I have made no changes. Perhaps my suspicion is true: something cached on the server side was not allowing more recent items to publish in the feed.

0 いいね!
pixl_labs
投稿者

related_blog_posts only shows some posts from blog

Do you have a live or test version I could check out? I'm happy to figure this out for you.

miljkovicmisa
トップ投稿者 | Platinum Partner
トップ投稿者 | Platinum Partner

related_blog_posts only shows some posts from blog

Hello @kevinpotts  and thank you for writing.

If you are using this function on a blog post template you should omit the blog_post_ids parameter as per the documentation:

Please note that if the related_blog_posts HubL tag is being used on a post, the blog_post_ids parameter should not be specified, as on blog posts, it will default to the post the widget is appearing on.

Otherwise if that's not the issue, please post some more details or a link to your page so we could debug it.

If my answer was helpful please mark it as a solution.

kevinpotts
参加者

related_blog_posts only shows some posts from blog

I am not using this on a blog post template. It is used on a page template. The concept is an "About" page that pulls in recent press release headlines. I've done this before using the RSS tag, but that feels a bit sloppy and I would like more explicit control over the markup.

0 いいね!