Help getting random posts to work
-
I’ve been trying to get a random post link (from a specific category) to display on my front page. After some searching through various hacks, I settled on Skippy’s hack.
But since I don’t want to have a specific php page that displays links like Skippy does, I tried to work with his hack to get it do what I want. Hence the dangerous part, since I’m just learning about the inner workings of WP.
Here’s what I tried:
<div id="menu">
<div id="nav">-
...other stuff from my right hand menu is here...
- ">Read a random poem!
- Read a random poem!
<?php include_once('./wordpress/random.php'); ?>
<?php $randpoem = random_posts('3', 1); ?>I’m using
./wordpress/random.php
because my index.php file lives in my root directory.random_posts('3', 1);
is supposed to grab just one post from category 3 (which is my poetry category).
Every time I refresh, I just get this:
That post isn’t in category 3, and even when I’ve changed the category number in the function to something else, it still always places that link there.
I’m confused and lost and wishing I knew more about the guts of WP. Can anyone help me get this to work or point me to a random post hack that will work better for me?
- The topic ‘Help getting random posts to work’ is closed to new replies.