Hallo Leute,
ich hoffe jemand von Euch kann mir helfen...
Ich würde gerne die Artikel auf der Startseite nach Zufall sortieren, so sieht der Code derzeit aus:
PHP
<?php
if (have_posts()) :
$categories = get_categories();
foreach($categories as $category) {
global $wpdb;
$sql = "SELECT p.ID, p.post_title, p.post_name, pm.meta_value "
."FROM ".$wpdb->posts." p
INNER JOIN ".$wpdb->term_relationships." r ON ( p.ID = r.object_id )
INNER JOIN ".$wpdb->postmeta." pm ON ( p.ID = pm.post_id AND pm.meta_key = 'thumbnail_url' )
INNER JOIN ".$wpdb->term_taxonomy." t ON ( r.term_taxonomy_id = t.term_taxonomy_id )
WHERE t.taxonomy = 'category' AND t.term_id IN (".$category->term_id.") AND p.post_status = 'publish'"
. "AND p.post_type = 'post' ORDER BY p.ID DESC LIMIT 0,6";
$posts = $wpdb->get_results($sql);
?>
Alles anzeigen
Wie und wo kann ich ORDER BY RAND einfügen? Derzeit wird es nur nach der Product ID, tausche ich den Code gegen RAND aus, funktioniert es leider nicht...
Beste Grüße