Jump to content

Getting Most Recent Pages


Adohgg
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...