Blog tags not showing on individual list items on the search results listing.
SOLVE
I'm looking for some help to get blog tags added to my individual search results items. Just like in the blog listing template we can add the topics/tags, I need to replicate the samen the search results page. How can I do this?
Blog tags not showing on individual list items on the search results listing.
SOLVE
@ScottD22 like @dennisedson is saying, you can loop through the tags on your results page/module inside of your results loop. What I would probably do is first create a new array from all the blog post results, then add all the tags to that new array from each blog post, then de-dupe it, and finally print those tags to the page.
So in Javascript that would look something like this:
// create new array
var allRelevantTags = [];
// loop through all blog posts
results.forEach(function(result, index){
// grab the blog post tags and add them to our tags array
allRelevantTags.push.apply(allRelevantTags, result.tags)
}
// remove duplicate tags
var uniqueRelevantTags = [...new Set(allRelevantTags)];
// print each tag to page
uniqueRelevantTags.forEach(item, index) {
document.body.appendChild(item);
}
Blog tags not showing on individual list items on the search results listing.
SOLVE
@ScottD22 My solution is really for showing all the tags outside of the posts. If you need to show the tags on each post/result it would be much easier. Basically, inside your loop where you are already looping through the results, add another loop to loop through the tags array. If you can show us the code you're using for your results I can be a better help. Thanks!
Blog tags not showing on individual list items on the search results listing.
SOLVE
Hey Stefen,
We have just cloned the search results from HubSpot in design tools. So the code if the default JS provided there. We want to show the tags on each post/result .
Blog tags not showing on individual list items on the search results listing.
SOLVE
Thanks for this Stefen, I'm now getting an error of Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node' in the console. No results are showing.