Simple php page to get post

I’m new at PHP (even though i’m coding in other languages(
I have done a route in cockpit, so my single blogposts are routed to /blog/post and now I want to create a php page to list the post (so that google can follow slug links)

I’ve tried a simple page as follows, but it doesn’t show anything.
Has anyone a simple example that works?


this code is an example, for me works.

  $project = cockpit('collections')->find('projects', [
    'filter' => [
      'published' => 'Published',
      'permalink' => $_GET['permalink']

  if ( empty( $project ) ) {
    return [
      'message' => 'Not found'


Your filter array seems incorrect.

Thank you allesandro!
It doesn’t work for me though. Am I including the right bootstrap.php?
It is the one in the root.

Do I need to provide token? If so, where do I put it?


  • jonah

strange, it should work. do yo get any errors?

also try $posts->toArray()

Hi Artur!
I needed to require the bootstrap file, instead of including it.
This is what I got now, and this works!
My url is as follows:

This is my code, for reference.


                $post = cockpit('collections')->find('posts', [
                    'filter' => ['slug' => basename($_SERVER['REQUEST_URI'])]

                $date = $post["date"];
                $title = $post['title'];
                $content = $post['content'];
                $featured_image = $post['feature_image'];

there shouldn’t be any difference between require and include :thinking:

No, you needed the brackets :wink:
<?php include('../admin/bootstrap.php'); ?>

Haha! :grimacing: