Hi, I am looking for a plugin that display random Pages on a widget in sidebar, trying to search on wordpress.org but only finding for posts anyone heard about this plugin? thanks
In fact you don't need a Plugin, just a Little code, like this : <?php $args=array( 'orderby' => 'rand', 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => 5, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo 'List of 5 random pages'; while ($my_query->have_posts()) : $my_query->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p> <?php endwhile; } wp_reset_query(); // Restore global post data stomped by the_post(). ?> Code (markup): Simple and Clean Goodluck
Better to use themes4all's code, but here's a few plugins: [*] http://wordpress.org/plugins/random-posts-widget-include/ [*] http://wordpress.org/support/topic/display-a-list-of-random-pages-without-plugin-widget
The first link the plugin is not Updated since 2 Years Ago so it's a bad idea to use a code which can be Malicious.. the Second link is just like the Code i passed in my Example there is 5 Pages to Display and this one use 3
ok, thanks a lot, but waht about dedicated pages 'like that page that one that one but not that one' ^^
You will add this code in sidebar, this will hep you <ul> <?php query_posts('posts_per_page=5&orderby=rand'); ?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <li><a href="<?php the_permalink() ?>"rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a> </li> <?php endwhile; ?> <?php endif; ?> </ul>
No that line you need to remove <?php echo 'list of 5 random pages' ?> You see the 'post_per_page'=> 5 that is mean, how many pages you want to display. so only change here 'post_per_page'=> 5 .