Wordpress Post Rotation? Front Page?

Status
Not open for further replies.

smash

New member
Mar 19, 2007
231
1
0
Victorville, CA
I've put together a wordpress blog with about 6,000 posts I've generated from some data. They are all legitimate content and all need to be there to serve the purpose of the site (for example, maybe it's different types of thumbtacks, or a site dedicated to the different models of power staplers). I've been looking for an automatic article rotator to update posts with the newest date to keep them rotating on the front page which in turn update the sidebar recent posts so that the content will look fresh to the search engines and users. Does anyone know of a plugin that manages to handle this, or is this something I'll have to write on my own?

Thanks!
 


So you would like to rotate the same 6000 posts over and over again? I don't believe there is any plugin I have heard of for wordpress. The only option I can think of is to just to write one yourself or rotate the posts manually. Maybe post a new one each day or something. That would last you for a few years. :D
 
So you would like to rotate the same 6000 posts over and over again? I don't believe there is any plugin I have heard of for wordpress. The only option I can think of is to just to write one yourself or rotate the posts manually. Maybe post a new one each day or something. That would last you for a few years. :D

Yup that's exactly what I was looking for. I might just have to write something that everyday grabs a random number and changes the post date to the current date/time, then I'll call it the random drink of the day, maybe I'll add it to all pages, that way they all are freshened up every day......hmmm........

That way my page content stays fresh by moving stuff around. It should work I believe.
 
I am looking for a plug-in or code I can put in a template that will allow you to display a random post from a specific category on your index.php In addition, it would allow you to identify multiple categories.

So, you would have 1 random post (or excerpt) from category A, 1 random post from category B, 1 rand... etc for howevery many specific categories you identify.

For your purpose, if you are only pulling from one category, I think that THIS PLUGIN might suit your needs. haven't tried it though. There is also a COMPLETE CATEGORY OF RANDOMNESS you can search through, but didn't find what I was looking for.

And let me know if you can help me out.

There HAS to be some snippet of code that says, "display random post from category-ID". And then I could just paste that numerous times in the template for the desired effect.

Hook a brotha up.
 
Place this:

Code:
<?php
$random_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY RAND() LIMIT 1");
query_posts("p=$random_id");
?>
Above this:

Code:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

On your index page, the above code may replace exisiting code - I don't remember and am half drunk right now....
 
Alright, I gotta give credit to this guy Matt from Dagon Design

He helped me out and came up with this code, inserted into what nacho already provided, and it pulls a random post from a specific category (category being 123 in this situation):

Code:
$random_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts, $wpdb->post2cat WHERE post_status = 'publish' AND post_id = ID and category_id=123 ORDER BY RAND() LIMIT 1");

Unfortunately, when i paste this more than once before the loop, it reverts to just showing the most recent posts. My end goal is to show 1 random post from each of 4 or 5 categories. Pasting this code 4 or 5 times doesn't work. You can only post once.

So that's where I'm at now... if you can contribute any more, cheers to ya.
 
I don't know if my plugin, Category Magic, might help you or not. It can pull as many random posts from a single category as you want, heck it even pulls random posts from a single random category. It can also only display posts that belong to two specific categories.

In displaying random posts from a single category, you could stack the calls one on top of the other.

One limitation it has now(I coded it that way to begin with) is that it only looks for the 1000 most recent posts in a category so if any category has more than 1000 posts, you would either need to let me know(and I will change it for you) or I can tell you where to change the code.

The second limitation is it only pulls the post title. This is meant for putting older and random post links into the sidebar. I assume you want the whole post. Since your's is an intriguing idea, I could hack on it and get it to display the entire post, but it might take a week before I get the time for it.

AX697.ORG » Blog Archive » Category Magic Plugin

(ps it's my first attempt at a plugin, but it has been working for several weeks with no errors or bugs)
 
Status
Not open for further replies.