Blog with particular tags on a dynamic page

Hi!
I would like to have a blog feed on a dynamic page, but the blog feed would only include articles with a particular tag, depending on the page. The tag would be the title of the page, actually.
Is that possible with Code? Note that the blog feed in question uses the Wix Blog model and isn’t a blog created with Wix Code and I want to keep it that way in order to make it simple for further posts.
Thank you for your help!

1 Like

There’s no way to programmatically change the feed settings.
Depending on how many tags you have, there might be a dirty workaround to get the same effect:

  • Add multiple feeds, each with a different tag filter.

  • Have them all hidden by default

  • Show just the one you need, using JavaScript and the .hide() function

Not really good in my case since we’re talking hundreds of pages… But thanks anyway for the reply! I’ll think I’ll just have to link it!

Need to do this exact thing. Is a less dirty way possible now?

You can’t use velo (or built in functions) to only show one hashtag, but what you can do is make a repeater that displays the elements of the blog posts and fill it with a filtered query search on the “Blog/Posts” database.

I don’t have time to do it, but the steps should be:

  1. Query “Blog/Posts”

  2. Put the results.items into an array

  3. each item has an array named “hashtag”, run trough each of those arrays, and if it hits a match with your desired hashtag add it to a seperate array

  4. After all that, populate a repeater with the array that contains all the items with matches
    That’s at least how I would do it.

@simen

Thank you for your reply. I got the code to work that gave me a filtered list of blog posts if one of the hashtags matched an element from a dynamic page, but then realized that categories would be closer to what I need… but harder.

Since Categories are a reference, I actually need the ID of the category to use in the hasSome filter on the Blog posts.

I have done all of this except figure out how to take the results of the Category query and convert it into a string that I can use in the hasSome filter.

@simen Thanks again for the general steps as it really helped keep me going in the right direction.

I figured out how to convert the category query result into a sting (with JSON.stringify() ) and then removed the quotes with .replace(). third query is now successfully populating with the filtered blog posts.

@jack14520 Happy to help! :slight_smile: