Listing recent posts and dynamically populating tags
SOLVE
This is probably an easy one for seasoned HubSpot devs, but that is NOT ME.
We have pages set up for each team member in the organization—I'm trying to display the three most recent blog posts that are tagged with that member's name. (These will be manually tagged.)
The wrinkle is these team member pages are being populated by a separate HubDB, so I need to pass the first and last name of the current member into the tag field. I've tried to set two variables to do this, but no dice.
Current code that does not work:
{% set name_var = "{{ dynamic_page_hubdb_row.first_name }}-{{ dynamic_page_hubdb_row.last_name }}" %}
{% set tag_posts = blog_recent_tag_posts('XXXXXXXXXX', ['{{ name_var }}'], 3) %}
<ul>
{% for tag_post in tag_posts %}
<li><a href="{{ tag_post.absolute_url }}">{{ tag_post.name }}</a></li>
{% endfor %}
</ul>
Listing recent posts and dynamically populating tags
SOLVE
Thanks yet again. I feel like that SHOULD have worked, but no luck. It really does seem that blog_recent_tag_posts doesn't like a variable for the tag name.
The blog_recent_tag_posts function is set that it will filter by slug. So make sure if you use our code to replace spaces with dashes and make all letters lower case.
Listing recent posts and dynamically populating tags
SOLVE
Thanks again, Indra
Definitely helpful, but the variable still isn't getting passed into the function. I can successfully echo {{ name_var }} (lowercase, with hyphen) pretty much anywhere but it doesn't seem to get inserted into the blog_recent_tag_posts string.
Since you want to filter by authors, you should use another function. So instead of using blog_recent_tag_posts, you should use blog_recent_author_posts.
Listing recent posts and dynamically populating tags
SOLVE
Thanks for the detailed response, Indra.
That’s not quite what I need here though—these blog posts aren’t necessarily authored by a particular team member, but instead are manually tagged with a team member’s name if they’re MENTIONED in the blog post.