if($random_post -> have_posts() ) {
while($random_post -> have_posts() ) {
$random_post -> the_post();
$listed='<a href="'.get_the_permalink().'">'.get_the_title().'</a>';
$pieces = explode(" " ,"$listed");
echo $pieces[ 0 ],$pieces[ 1 ],$pieces[ 2 ],$pieces[ 3 ];
}
}
This snippet makes it look like you have yourself a little crossed up. I assume you want a different link for each item? If that’s what you want, you can write it like so:
if ($random_post->have_posts() ) {
while ($random_post->have_posts() ) {
$random_post->the_post();
echo '<div class="ticker-item"><a href="'.get_the_permalink().'">'.get_the_title().'</a></div>';
}
}
The while
loop will run once for each post in your list. You want to print out a link for each item in the list, so that’s all you do.