# Search for pinned topics

**URL:** https://meta.discourse.org/t/search-for-pinned-topics/36208
**Category:** Feature
**Tags:** search
**Created:** [December 1, 2015, 6:20pm UTC](https://meta.discourse.org/t/search-for-pinned-topics/36208 "2015-12-01T18:20:02Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [December 1, 2015, 6:20pm UTC](https://meta.discourse.org/t/search-for-pinned-topics/36208/1 "2015-12-01T18:20:02Z")

</div>

Continuing the discussion from [What advanced search filters should exist?](https://meta.discourse.org/t/what-advanced-search-filters-should-exist/20933/7):

> [@BhaelOchon](#):
>
> `is:pinned`  
> `is:unpinned`
> 
> …so I can see which topics are pinned and unpinned for myself.

Can’t seem to find an answer for this here yet…can you search for pinned topics?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [December 1, 2015, 7:07pm UTC](https://meta.discourse.org/t/search-for-pinned-topics/36208/2 "2015-12-01T19:07:28Z")

</div>

If I’m correct the available search filters come from /lib/search.rb

There are several “advanced\_filter” lines but I see none for “pinned”

Unfortunately it might be a bit complex to code up.

The topics table has

```plaintext
pinned_at timestamp without time zone,
pinned_globally boolean DEFAULT false NOT NULL,
pinned_until timestamp without time zone,

```

and the topic\_users table has

```plaintext
cleared_pinned_at timestamp without time zone,

```

I think something simple like

```plaintext
  advanced_filter(/status:pinned/) do |posts|
    posts.where('topics.pinned_at')
  end

```

might work, but accounting for when / if it is / will be un-pinned would take a bit more

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [December 2, 2015, 3:38am UTC](https://meta.discourse.org/t/search-for-pinned-topics/36208/3 "2015-12-02T03:38:23Z")

</div>

The pinned search should exist @sam

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 18, 2016, 5:28am UTC](https://meta.discourse.org/t/search-for-pinned-topics/36208/4 "2016-03-18T05:28:08Z")

</div>

Implemented per:

[https://github.com/discourse/discourse/commit/77242e4680d310d0c152396824713ca2f8eb275a](https://github.com/discourse/discourse/commit/77242e4680d310d0c152396824713ca2f8eb275a)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 18, 2016, 5:28am UTC](https://meta.discourse.org/t/search-for-pinned-topics/36208/5 "2016-03-18T05:28:11Z")

</div>


