Hello
I think ave found a critical bug in HubSpot that I cannot find a solution for.
After reading all the HubSpot documentation and comparing it with other projects and HubSpots I manage, I’ve concluded that this is an issue on HubSpot’s part that I can’t fix it I think.
I’ll try to explain.
I have a blog with different articles, and each blog post has only one associated tag (not multiple). At the end of each article, there is a “Similar posts” section. However, when I use the code to fetch similar posts and print the tag variable I am passing as a parameter, it does not return the correct results.
For example, if I open a post with the tag “Recruitment,” it works fine, but with the tag “sales,” it does not work.
And if you check my code screenshots, you can see that everything is correct and the variable containing the tag is printing correctly. So, I don’t understand how a post with the tag “sales” is showing related posts that are not about sales.
Thanks for the additional details @JDoxy07, thats what I suspected, I just wanted to be sure.
Without being able to dig into the code and try to recreate the issue, I’m not sure how else I can help - it looks like you have identifying info blurred and can’t share the code or link directly.
Perhaps @Anton can spot something in the code that you and I have missed.
The only thing it does is checking if there’s any tag available. Unless you’re checking for “if featured_tag equals post_tags” somewhere in your code/macro it will only do the following:
“If tag is available show posts with the tag - else - show other posts”
And this is what your code does. So I’d assume that there’s no logic that matches the featured_tag to post_tags.
Have you tried something like this:
{% if featured_tag == post_tags[0] %}
...
if the post_tag matches
{% else %}
...
if the post_tag doesn't match
{% endif %}
best,
Anton
Moderator note: While this solution may not address the original poster’s specific situation, it could be helpful for other community members facing similar challenges.
However, the feature_tag and the post_tag are exactly the same.
I included both approaches so you could see and verify through data-feature-tags and data-posts-tags what the variables were outputting at that moment.
And as you can see, they are printing correctly.
They always enter the first if statement.
So, it should have been done correctly.
Remember that removing the if statements and leaving just this instruction:
Hello @Jnix284 thanks a lot for you help.
The information that is blurred is just the blog post title. It’s only important to check that the tags on the images are correct.
And in the code, I simply applied a blur to the name of a class.