Skip to content

document how to add craft singles to index #360

Answered by janhenckens
npegman asked this question in Q&A
Discussion options

You must be logged in to vote

You can of course query all singles, parse those and pass them to the query. For example (for Craft 5):

$sections = Craft::$app->getEntries()->getSectionsByType('single');
$handles = collect($sections)->map(function ($section) {
    return $section->handle;
})->toArray();
query->section($handles);

You can of course then also merge that array with a different one of different sections

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by janhenckens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #357 on February 06, 2025 08:43.