2017-08-26, 23:37:52
(2013-08-01, 01:40:22)Angryboy Wrote: Hopefully this is a cleaner and easier to understand way of doing what I mentioned before (again, using return_i18n_search_results, since its purpose is for custom outputs)
PHP Code:<?php
// total number of results
$total = 5;
// change parameters (except $max) to ones relevant to your search)
$search = return_i18n_search_results($tags=null, $words=null, $first=0, $max=999, $order=null, $lang=null);
// apply this function as many times as you want to throughly shuffle the results
shuffle($search['results']);
// now limit the results to the max number
$search['results'] = array_slice($search['results'], 0, $total);
// loop through each result and output as desired
foreach ($search['results'] as $result) {
// output
}
?>
Hello,
thank you for the snippet, but could you please tell me what to write in the foreach-loop to display the results in the same way as if i'd use "get_i18n_search_results(array('tags'=>'news','words'=>' ', 'max'=>3,'numWords'=>10,'HEADER'=>null)); ?>"?
I tried "echo $result->content;" but that doesn't output anything.
However, the "echo $result->url;" outputs the desired random page slugs.
Thank you very much in advance.
Cheers.
Shasaar