Display a list of (x) most recent blog entries
Last modified: August 8, 2008 - 11:55
PLEASE NOTE: The php snippets are user submitted and it is impossible to check every one, so use at your own risk. For users who have setup drupal using an alternate database to the default, please note that the snippets may contain some database queries that may or may not work.
<?php
/**
* The following displays a list of the 10 most recent blog titles
* as links to the full blogs. If you want to increase/reduce
* the number of titles displayed, simply change $listlength value.
*
*/
$listlength="10";
$nodetype="blog";
$output = node_title_list(db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = '%s' AND n.status = 1 ORDER BY n.created DESC"), $nodetype, 0, $listlength));
print $output;
?>This can be extended to use the pager, like so.
<?php
$listlength="10";
$nodetype="blog";
$output = node_title_list(pager_query(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = '%s' AND n.status = 1 ORDER BY n.created DESC"), $nodetype, $listlength));
$output .= theme('pager', NULL, $listlength);
print $output;
?>