Mijo 5 Posted February 3, 2018 Hello all, I'm trying to get all selected tags on my news list, so far when I go to specific news I see tags that I selected for that news, but when I'm on news list I see all tags that exists, not once that I selected. Tag field is page reference, I have selected Multiple pages (page array), input field type Amselect. My code so far looks like this: <?php $tags = $pages->get("/tag/")->find(); foreach($tags as $tag){ echo "<li><a href='{$tag->url}'>{$tag->title}</a></li>"; } ?> Can you help please with some advice how to get only selected tags on my news list? Share this post Link to post Share on other sites
adrian 12,061 Posted February 4, 2018 I think what you are looking for is: foreach($page->tags as $tag) { echo "<li><a href='{$tag->url}'>{$tag->title}</a></li>"; } I assume when you say "go to specific news" that means a page with a single news item. Share this post Link to post Share on other sites
Mijo 5 Posted February 4, 2018 3 hours ago, adrian said: I think what you are looking for is: foreach($page->tags as $tag) { echo "<li><a href='{$tag->url}'>{$tag->title}</a></li>"; } I assume when you say "go to specific news" that means a page with a single news item. Thanks for the reply but unfortunately it does not work, tags are not showing. With my code above I achieve that tags (selected tags for news item) showing on single news, for example test 1, test 2 but when I am on to news list I see all tags that I have created. Share this post Link to post Share on other sites
PWaddict 373 Posted February 4, 2018 @Mijo Try this: //Grabbing the news list $posts = $page->children("limit=10"); //Rendering each news post foreach($posts as $post) { echo "Lorem Ipsum..."; //Rendering selected tags inside each post foreach($post->tags as $tag) { echo "<li><a href='{$tag->url}'>{$tag->title}</a></li>"; } } 1 1 Share this post Link to post Share on other sites
Mijo 5 Posted February 5, 2018 19 hours ago, PWaddict said: @Mijo Try this: //Grabbing the news list $posts = $page->children("limit=10"); //Rendering each news post foreach($posts as $post) { echo "Lorem Ipsum..."; //Rendering selected tags inside each post foreach($post->tags as $tag) { echo "<li><a href='{$tag->url}'>{$tag->title}</a></li>"; } } Thank you very much! Share this post Link to post Share on other sites