By default the results in PlayTube are sorted by oldest. In order to sort the results by newest, we need to make a small core modification. This isn’t tested with the latest version of PlayTube as I am still on the 1.4.3 version, but the modification is simple, just change ASC to DESC.
Find in /sources/search/content.php
1 2 3 4 5 6 7 8 9 |
if ($pt->config->total_videos > 1000000) { $get_videos = $db->rawQuery("SELECT * FROM " . T_VIDEOS . " WHERE MATCH (title) AGAINST ('$keyword') ORDER BY id ASC LIMIT 20"); } else { $get_videos = $db->rawQuery("SELECT * FROM " . T_VIDEOS . " WHERE title LIKE '%$keyword%' ORDER BY id ASC LIMIT 20"); } |
Replace with
1 2 3 4 5 6 7 8 9 |
if ($pt->config->total_videos > 1000000) { $get_videos = $db->rawQuery("SELECT * FROM " . T_VIDEOS . " WHERE MATCH (title) AGAINST ('$keyword') ORDER BY id DESC LIMIT 20"); } else { $get_videos = $db->rawQuery("SELECT * FROM " . T_VIDEOS . " WHERE title LIKE '%$keyword%' ORDER BY id DESC LIMIT 20"); } |
Thats it, now your search results are setup to show the latest videos under that search query. Don’t forget to setup Site Search on Google Analytics.