Jump to content

How to list Child Pages blog style


sam-vital
 Share

Recommended Posts

Hi,

I'm creating a News/Updates section for a client and they would like the 3 most recent Updates previewed on the home screen. So this would be Title and Date Posted. These blog posts will be child pages of a News and Updates page, which is a child of the Home page. So it's like Home -> News -> Blog posts. I don't need this to be a nav menu, just something to show the newest updates.

All help is appreciated ?

Link to comment
Share on other sites

$mostRecent = $pages->find("parent=123, template=news, sort=-modified, limit=3");
foreach($mostRecent as $teaser) {
	echo "<h3><a href='{$teaser->url}'>{$teaser->title}</a></h3>";
}

123 is simply the id of the parent page, under which your news/blog pages live

Read more about selectors:
https://processwire.com/api/selectors/

And keep this bookmarked:
http://cheatsheet.processwire.com/

 

 

  • Like 2
Link to comment
Share on other sites

15 minutes ago, dragan said:

$mostRecent = $pages->find("parent=123, template=news, sort=-modified, limit=3");
foreach($mostRecent as $teaser) {
	echo "<h3><a href='{$teaser->url}'>{$teaser->title}</a></h3>";
}

123 is simply the id of the parent page, under which your news/blog pages live

Read more about selectors:
https://processwire.com/api/selectors/

And keep this bookmarked:
http://cheatsheet.processwire.com/

 

 

Thank you!

Works a treat

Link to comment
Share on other sites

 Share

×
×
  • Create New...