Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Link to show a random blog (Mu/MultiSite) WordPress

  • REFUNDED

On my site, I have a menu option for showing a random blog, but I can't figure out what I need to do to link to a random blog.

I'm using the new menus system of WordPress 3.

Answers (3)

2010-08-13

Pippin Williamson answers:

Here you go:

http://wordpress.org/extend/plugins/random-redirect/


Pippin Williamson comments:

Whoops, you said random blog, sorry.

You wish probably require a membership, but here's another one:

http://patrick.bloggles.info/plugins/

It's number 12 in the list.


Joe Jenkins comments:

I saw about the /?random when I was tryign to figure this out, but that is for a specic blog.

I'm looking for a way to show info on a random blog:

blog1.testsite.com, blog2.testsite.com, blog3.testsite.com, etc


Pippin Williamson comments:

Take a look at the second link I posted.


Joe Jenkins comments:

Ah, I messied that one while I was writing.

That link doesn't go to the plugin anymore, it just links directly to premium.wpmudev.org, and the plugin isn't available on there :( It looks like the exact thing I was after.

2010-08-13

Eddie Moya answers:

Stick this in your functions.php


function random_blog_link(){
$blog_list = get_blog_list( 0, 'all' );
$rand = rand(1, count($blog_list));
echo '<a class="random_blog_link" href="' . $blog_list[$rand]['path']. '">' . get_blog_option( $blog_list[$rand]['blog_id'], 'blogname' ) . '</a>';
}


Then just call the function wherever you need your random link. It will generate the entire link including <a href=""> and </a>.

<strong>Warning, this will work on 3.0 - however it is based on something I did for 2.9.2. The functions used here are deprecated and may not work in future version.
</strong>


Joe Jenkins comments:

How would I call that funtion using the menu system in wp3 admin?


Joe Jenkins comments:

I add this to a custome link:

<? phpechoget_option('blogname'); ?>

After saving the menu, I end up with this:

http://?phpechoget_option('blogname');?


Joe Jenkins comments:

Sorry, I just pasted in something totally different.

I'll try that again.


I add this to a custom link:

<?php echo get_option('random_blog_link'); ?>

After saving the menu, I end up with this:

http://?phpechoget_option('random_blog_link');?


Eddie Moya comments:

The link is not saved as an option. You should be calling it as such:


<!--whatever html you have before the link -->
<?php random_blog_link(); ?>
<!--whatever html you have after the link-->


A more realworld example might look like this ...


<div>
<h2>
Behold! A Random Blog Link!
</h2>
<?php random_blog_link(); ?>
</div>


Again... you dont need to create the <a href=""> </a> parts yourself.. the function i made for you does all that. And its not being added to the options table. All you should need to do it call the function itself.

Last Note: You dont need to use <strong>echo</strong> with this function. It does that on its own. You just need to call the function in the place where you want that link to appear.



Eddie Moya comments:

A little explanation might be due. The reason I have the function create the entire link instead of just the url is because you need the blog name to show up as the title (i presume) of the link. So for simplicities sake I just did it all at once.

2010-08-13

powerflash answers:

You can use "Random Blog Redirect" plugin , this is specific for WP MU but I think that with WP 3 multisite it work
Plugin URI: http://mu.bloggles.info/

when activated every you browse this url mydomainblog.com/?random it redirect to random blog url