Adohgg Posted September 13, 2013 Share Posted September 13, 2013 function newsList(){ // Grab the page name from the url $thisCategory = wire("page")->name; // If the category is not called "news" then output the category name as a selector for the find. if($thisCategory !="news") { $category = "article_category.name=" . $thisCategory; } // Get the news posts - limited to ten for later pagination $newsposts = wire("pages")->find("parent=/news-articles/, $category, template=TUT_news, limit=3"); $out =" "; //Loop through the pages foreach($newsposts as $newspost){ $out .="<div class='clearfix'>"; if($newspost->article_thumbnails){ $out .="<a href='{$newspost->article_thumbnails->url}' class=''>"; $out .="<img class='align_left' src='{$newspost->article_thumbnails->getThumb(listingthumb)}'>"; $out .="</a>"; } $out .="<a href='{$newspost->url}'><h3>{$newspost->title}</h3></a>"; $out .="<p>{$newspost->article_introtext}</p>"; $out .="</div>"; } echo $out; } I'm trying to use this code to get the most recent pages created and display them. I found this code on the wiki, but how would I make it display the most recent ones instead of the oldest ones? Link to comment Share on other sites More sharing options...
MatthewSchenker Posted September 14, 2013 Share Posted September 14, 2013 Greetings, If I am reading your needs correctly, you add this to your "find" statement: sort=-date Thanks, Matthew Link to comment Share on other sites More sharing options...
kongondo Posted September 14, 2013 Share Posted September 14, 2013 Btw, this was a double post and a similar response was posted by Adrian http://processwire.com/talk/topic/4503-getting-most-recent-pages/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now