You are required to register before you can post. This is via a custom verification system. Please post any problems you are encountering here and I`ll do my best to respond as soon as I can. Please note that a reply WILL be posted to all queries, so do not double post. There are no guarantees
when a reply will appear but I do my best to answer all within 3/4 days max. Bumping topics won`t make the slightest difference.
IMPORTANT: Posts in English ONLY please, thank you! Any other languages will be ignored and your message deleted.
SEARCH: Use the search option to see if your question has been answered on the forum before. Or check the relevant script docs.
CUSTOMER: If you have purchased a commercial version of any of my software, using the contact option at the licence centre ensures a faster response.
AUTO DELETION: Accounts older than 5 days, with no posts or topics, are automatically deleted. Only register if you are thinking of posting.
PRIVATE MESSAGES: Private messages are currently disabled.
LINKS: Any links posted are 'NOFOLLOW' and will not be picked up by search engines.
You are not logged in.
Pages: 1
How can I limit the archive page to show the latest 5 blog posts instead of all blogs?
Offline
In the main index.php file around line 529 you`ll see:
$q_archive = mysql_query("SELECT * FROM ".$database['prefix']."blogs
".($cmd=='archive' ?
'WHERE archiveMonth = \''.$a_month.'\' && archiveYear = \''.$a_year.'\'' :
'')."
ORDER BY title
LIMIT $limitvalue,$SETTINGS->total") or die(mysql_error());
Change to:
$q_archive = mysql_query("SELECT * FROM ".$database['prefix']."blogs
".($cmd=='archive' ?
'WHERE archiveMonth = \''.$a_month.'\' && archiveYear = \''.$a_year.'\'' :
'')."
ORDER BY id
LIMIT 5") or die(mysql_error());
You`ll probably want to remove the page numbers as well.
Offline
How about limiting the results to the most current dates and not in alphabetical order? Thanks again.
Offline
When you say, most current dates, what range are you looking for? Today? Last week? Month?
Offline
current month I suppose? I would like to show the five most current blogs written.
Offline
$q_archive = mysql_query("SELECT * FROM ".$database['prefix']."blogs ORDER BY id LIMIT 5") or die(mysql_error());
Offline
Thanks again. Works great. For those who wish to have the list in descending order, I've figured out how to edit the code to this.
$q_archive = mysql_query("SELECT * FROM ".$database['prefix']."blogs ORDER BY id DESC LIMIT 5") or die(mysql_error());
Last edited by duceduc (22-02-2011 13:16:31)
Offline
Yes, thats correct. ![]()
Offline
Thank you so much for this post! I did not want my archive limited; but I did want it to sort posts by date in descending order; not alphabetically. This was a quick fix: ORDER BY id DESC
// Second query returns the data with limit clause for pagination..
$q_archive = mysql_query("SELECT * FROM ".$database['prefix']."blogs
".($cmd=='archive' ?
'WHERE archiveMonth = \''.$a_month.'\' && archiveYear = \''.$a_year.'\'' :
'')."
ORDER BY id DESC
LIMIT $limitvalue,$SETTINGS->total") or die(mysql_error());
I love this blog.
Offline
Excellent, glad you like it. ![]()
Offline
Pages: 1