WP plugin code help!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eroticfem
    Confirmed User
    • Sep 2009
    • 362

    #1

    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');
    
    ?>
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #2
    Originally posted by eroticfem
    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');
    
    ?>
    are you just trying to show a random post via dashboard?

    using query_posts is a bit outdated for this, what is the exact scope you are trying to do, cause this will do nothing for people actually visiting the site.
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

    Comment

    • eroticfem
      Confirmed User
      • Sep 2009
      • 362

      #3
      I was testing out plugins that would hopefully randomize x- posts from each categories once a day or on each reload. And this is no longer being updated thats why i posted it here, maybe it would be possible to get it working ...

      Comment

      • fris
        Too lazy to set a custom title
        • Aug 2002
        • 55679

        #4
        Originally posted by eroticfem
        I was testing out plugins that would hopefully randomize x- posts from each categories once a day or on each reload. And this is no longer being updated thats why i posted it here, maybe it would be possible to get it working ...
        you can run a filter on your posts so it loads them on random each load, let me know the full scope you want, every bit of info so i can code up and give it to you.
        Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

        Comment

        Working...