Random post in sidebar
-
Hello everybody,
I’m trying to simply display 3 random post on my page’s sidebar widget, but somehow its not working. I’m using following code:
<ul> <?php $args = array( 'numberposts' => 5, 'orderby' => 'rand', 'post_status' => 'publish', 'offset' => 1); $rand_posts = get_posts( $args ); foreach( $rand_posts as $post ) : ?> <li><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2><p><?php //the_excerpt(); ?> </p></li> <?php endforeach; ?> </ul>
I’ve installed php exec plugin so it executes php in sidebar.
thanks,
gautam
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Random post in sidebar’ is closed to new replies.