GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   WP plugin code help! (https://gfy.com/showthread.php?t=1135309)

eroticfem 03-07-2014 09:50 AM

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? :helpme

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 03-07-2014 09:57 AM

Quote:

Originally Posted by eroticfem (Post 20007763)
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? :helpme

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.

eroticfem 03-07-2014 10:13 AM

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 ...

fris 03-07-2014 11:50 AM

Quote:

Originally Posted by eroticfem (Post 20007796)
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.


All times are GMT -7. The time now is 08:53 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123