Here's the entire function:
function blogList(){
// Grab the page name from the url
$thisCategory = wire("page")->name;
// If the category is not called "blog" then output the category name as a selector for the find.
if($thisCategory !="blog") {
$category = "Category.name=" . $thisCategory;
}
// Get the blog posts - limited to five for later pagination
$blogposts = wire("pages")->find("parent=/article/, $category, limit=5, sort=-created");
rsort($blogposts);
$out =" ";
//Loop through the pages
foreach($blogposts as $blogpost){
$out .="<div class='posts sidemeta'>";
$out .="<div class='post'>";
$out .="<div class='date-wrapper'>";
$out .="<div class='date'>";
$out .="<span class='month'>{$blogpost->published_date}</span>";
$out .="</div><!-- /.date -->";
$out .="</div><!-- /.date-wrapper -->";
$out .="<div class='post-content'>";
$out .="<h2 class='post-title'>";
$out .="<a href='{$blogpost->url}'>{$blogpost->headline}</a>";
$out .="</h2>";
$out .="<ul class='meta'>";
$out .="<li class='categories'><a href='{$blogpost->Category->httpUrl}''>{$blogpost->Category->title}</a></li>";
$out .="<li>{$blogpost->author_name}</li>";
$out .="</ul>";
$out .="<p>{$blogpost->abstract}</p>";
$out .="<a href='{$blogpost->httpUrl}' class='btn'>Read more</a>";
$out .="</div>";
$out .="</div>";
$out .="</div>";
}
// Pagination
$out .="<div class='pagination'>";
$out .= $blogposts->renderPager(array(
'nextItemLabel' => "Next",
'previousItemLabel' => "Prev",
'listMarkup' => "<ul>{out}</ul>",
'itemMarkup' => "<li>{out}</li>",
'linkMarkup' => "<a class='primary-color' href='{url}'>{out}</a>"
));
$out .="</div>";
echo $out;
}
Thanks again for your help.