Forum
perch_content_custom and hidden pages
I'm using the following to output data from the 'Program overview' region on a bunch of pages:
<?php
perch_content_custom(['Program overview'], [
'page' => '/internships/*',
'template' => 'listings.html',
'count' => 100,
'sort'=>'overview_country',
'sort-order'=>'ASC',
'each' => function($item) {
$item['page_title'] = perch_page_attribute('pageTitle', array(
'_id' => $item['_pageID'],
), true);
return $item;
},
]);
?>
It works but the issue is it also includes any pages which I have ticked 'hidden from main navigation'. Is there a way I can keep those pages hidden and not have them output to the page as they are now?
You can use
perch_page_attribute()
to check if the page is hidden in the same way you're getting the title.I copied and pasted that function from another forum post I found so don't actually know how to write that code myself! Any chance you could provide the example? Thanks for help so far.
I would try:
Ok thanks, this is my final code and it seems to work: