View Single Post
Old 03-07-2014, 09:50 AM  
eroticfem
Confirmed User
 
Join Date: Sep 2009
Location: Europe
Posts: 362
WP plugin code help!

I found this randomize plugin and it works great, but the problem is that it has an issue with the pages. When active it random the posts but when i click on a new page it does not move from page 1 to 2 etc. Anyone know how to fix that in this code?

Code:
if(!get_option("post_randomize")) update_option("post_randomize","true");

function post_randomizer () {
	if (get_option("post_randomize")=="true") {
		if (is_home() || is_feed()) query_posts("orderby=rand");
	}
}
function postrandomizer_widget_initial () {
	wp_add_dashboard_widget("Post Randomizer","Post Randomizer","postrandomizer_widget");
}
function postrandomizer_widget() {
	global $wpdb;
	if ($_POST["postrandom"]<>"") {update_option("post_randomize","true");echo "<div class='updated fade'>Setting saved</div>";}
	if ($_POST["postunrandom"]<>"") {update_option("post_randomize","false");echo "<div class='updated fade'>Setting saved</div>";}
	$stat = get_option("post_randomize");
	if ($stat=="true") $current="Randomized";
	else $current = "Normal Order";
	echo "Current Status: <div align='center'><h1>$current</h1> Randomize the displayed post on your homepage and on the feed. It will be useful for site or blog that not daily updated so when the visitor come stopping by on your homepage, he won't see same posts or contents twice. <a href='http://mr.hokya.com/post-randomizer/' target='_blank'>See more</a>";
	echo "<p><form method='post'><input name='postrandom' type='submit' value='Randomize' class='button-primary'/><input name='postunrandom' type='submit' value='Do not Randomize' class='button-primary'/></form></p></div>";
}

add_action('wp_dashboard_setup', 'postrandomizer_widget_initial');
add_action('get_header', 'post_randomizer');
add_action('atom_head', 'post_randomizer');
add_action('rss_head', 'post_randomizer');
add_action('rss2_head', 'post_randomizer');

?>
__________________
eroticfem is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote