Display a list of 5 posts selected randomly by using the MySQL RAND() function for the orderby parameter value:
<ul> <?php $args = array( 'posts_per_page' => 5, 'orderby' => 'rand' ); $rand_posts = get_posts( $args ); foreach ( $rand_posts as $post ) : setup_postdata( $post ); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; wp_reset_postdata(); ?> </ul>
Laxman i am trying to learn php did you help me in learning
LikeLike
Sure i help u… 🙂
but u learn only php or php with wordpress ?
LikeLike
Thank you bro laxman for reply
i am learning php & wordpress both
LikeLike
Ok
Open this : http://en.gravatar.com/laxman92
LikeLike