Page title for layout variable and perch_blog_post_field

  • Hi, is there a perch content equivalent of perch_blog_post_field. I'm looking to replicate this for a list and detail page.


    $title = perch_blog_post_field(perch_get('s'), 'postTitle', true);

    perch_layout('global.header', array(




    In the above code I'd want to relace postTitle with serviceTitle. Does anyone know what I could put in place of perch_blog_post_field to get the serviceTitle from the query or am I completely barking up the wrong tree.


  • Hi Tom,

    It sounds like you have a multiple-item region. You can use perch_content_custom() and use the skip-template option to have the item's data returned as an array:

    1. $service = perch_content_custom('Services', [
    2. 'skip-template' => true,
    3. 'filter' => 'slug',
    4. 'match' => 'eq',
    5. 'value' => 'some-service',
    6. ]);
    7. if(isset($service[0]['seviceTitle'])) {
    8. $title = $service[0]['serviceTitle'];
    9. }
  • The code above is to demonstrate how to use the skip-template option and was not meant to be a copy-and-paste solution. Whether you need to use perch_get() depends on your set up.

    perch_get('s') gets you the value of the URL parameter ?s=:

    1. // URL is /services?s=my-slug
    2. $slug = perch_get('s');
    3. // URL is /services?page=2
    4. $page = perch_get('page');