Forum Replies Created
-
In reply to: Random Topic Link
Stephen, Now, Obviously, I would plunk that function in my functions.php page, but the two main things that I would like to specify is:
- I need to put this link in a menu
- I would like to specify particular forums the random would link to.
Is this possible with what you have supplied?
In reply to: Random Topic LinkDo I need to remove the functions in the function.php page? Because all I am getting is a blank white page.
In reply to: Random Topic Linkcould I put that in a page or post, rather than the code?
In reply to: Random Topic LinkHEY!
I just realized that you are calling $wp.
If the prefix for my database was changed, would this have anything to do with why it is not working?
In reply to: Random Topic LinkBTW.. I tried both versions of the $posts = get_posts() calls.
In reply to: Random Topic Linkok… so I pasted the following into my functions.php page:
add_action('init','random_post'); function random_post() { global $wp; $wp->add_query_var('random'); add_rewrite_rule('random/?$', 'index.php?random=1', 'top'); } add_action('template_redirect','random_template'); function random_template() { if (get_query_var('random') == 1) { $posts = get_posts('post_type=post&orderby=rand&numberposts=1'); foreach($posts as $post) { $link = get_permalink($post); } wp_redirect($link,307); exit; } }
And then in my menu I created a LINK element and pasted this into the URL field:
/?random=1
And all I get is a blank page
In reply to: Random Topic LinkSweet… do I could just put the: “/?random=1” in the URL field of a menu item and BLAM
Fantastic.Say I wanted to pull from two specific forum topics, how would I incorporate that?