We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b81d49e commit e1c64f5Copy full SHA for e1c64f5
src/Models/Traits/HasContentEntry.php
@@ -5,6 +5,7 @@
5
use Illuminate\Database\Eloquent\Casts\Attribute;
6
use Statamic\Facades\Entry;
7
use Statamic\Facades\Site;
8
+use Statamic\Statamic;
9
10
trait HasContentEntry
11
{
@@ -14,7 +15,7 @@ protected function entry(): Attribute
14
15
return Attribute::make(
16
get: fn() => Entry::query()
17
->where('collection', $this->collection)
- ->where('site', Site::selected()->handle())
18
+ ->where('site', Statamic::isCpRoute() ? Site::selected()->handle() : Site::current()->handle())
19
->where($this->linkField, $this?->{$this->getKeyName()} ?? null)
20
->first(),
21
)->shouldCache();
0 commit comments