You need to use tvfilters. Here's how:
[[!getResources? &parents=`4` &limit=`5` &tpl=`blogPost` &includeContent=`1` &showHidden=`1` &tvFilters=`tags==%[[*customtag]]%`]]
This would force getResources to only return resources that contain the tag
customtag.
If you want more than one tag, you would use the or filter:
[[!getResources? &parents=`4` &limit=`5` &tpl=`blogPost` &includeContent=`1` &showHidden=`1` &tvFilters=`tags==%[[*customtag]]%||tags==%[[*customtag2]]%||`]]
The percentage sign (%) searches for the exact values.
More on this on the official
getResources documentation page.
You should probably call your getResources uncached or use a cache manager extra like getCache. This could speed up the pageload for your users and your server will buy you a beer if you do that.
[ed. note: treigh last edited this post 13 years, 5 months ago.]