# Query posts for a multiselect

**URL:** <https://forum.getkirby.com/t/query-posts-for-a-multiselect/25240>\
**Category:** Questions\
**Tags:** v3\
**Created:** [April 12, 2022, 12:43pm UTC](https://forum.getkirby.com/t/query-posts-for-a-multiselect/25240 "2022-04-12T12:43:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwssnr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jwssnr/32/11727_2.png) [@jwssnr](https://forum.getkirby.com/u/jwssnr)\
**Post date:** [April 12, 2022, 12:43pm UTC](https://forum.getkirby.com/t/query-posts-for-a-multiselect/25240/1 "2022-04-12T12:43:50Z")

</div>

I want to query posts for a multiselect value and can’t get it to work. Here is my initial situation, which works in one place.

```auto
artists:
	label: Betrifft folgende Artists
	type: multiselect
	options: query
	query: site.page("artists").children

```

```auto
<?php foreach ($page->children() as $item): ?>
<?php $artist = $item->artists()->toPages(','); ?>
	<ul>
		<?php foreach($artist as $bla): ?>
		<li>
		<a href="<?= $bla->url() ?>"><?= $bla->title() ?></a>
		</li>
		<?php endforeach ?>
	</ul>
<?php endforeach ?>

```

# But on another place …

I like to filter those news by a custom “artist” in the “artists” multiselect.  
Intuitivley I tried this, suspecting that it would not work.

```auto
<?php $bla = $pages->find('news')->children()->filterBy('artists', 'in', 'Carl Andre') ?>

```

To check if it’s really just this secific filtering I tried it by title and it worked.

```auto
<?php $bla = $pages->find('news')->children()->filterBy('title', 'Rhabarber') ?>

```

I think I somehow need to split «artists» up but I have no idea how.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [April 12, 2022, 5:08pm UTC](https://forum.getkirby.com/t/query-posts-for-a-multiselect/25240/2 "2022-04-12T17:08:59Z")

</div>

```auto
<?php $result = $pages->find('news')->children()->filter(function($child) {
  return $child->artists()->toPages(',')->findBy('title', 'Some title');
});

```

If you are actually on the single artist page and want to get all the news related to the artist, you can also do it like this:

```auto
<?php $result = $pages->find('news')->children()->filter(function($child) use($page) {
  return $child->artists()->toPages(',')->has($page);
});

```

---

<div class="post-metadata">

**Author:** ![jwssnr](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jwssnr/32/11727_2.png) [@jwssnr](https://forum.getkirby.com/u/jwssnr)\
**Post date:** [April 12, 2022, 5:58pm UTC](https://forum.getkirby.com/t/query-posts-for-a-multiselect/25240/3 "2022-04-12T17:58:31Z")

</div>

Thank you so much!
