logo

$5
Link to show a random blog (Mu/MultiSite)

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.

Joe Jenkins | 08/13/10 at 2:15pm | Edit


(3) Possible Answers Submitted...

Note: Joe Jenkins felt their question was unanswered, so we granted them a refund.

Note: Joe Jenkins requested a refund. They offered no explanation.

  • avatar
    Last edited:
    08/13/10
    2:28pm
    Pippin Williamson says:

    Here you go:

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

    • 08/13/10 2:31pm

      Pippin Williamson says:

      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.

    • 08/13/10 2:31pm

      Joe Jenkins says:

      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

    • 08/13/10 2:36pm

      Pippin Williamson says:

      Take a look at the second link I posted.

    • 08/13/10 2:43pm

      Joe Jenkins says:

      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.

  • avatar
    Last edited:
    08/13/10
    4:52pm
    Eddie Moya says:

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

    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.

    Previous versions of this answer: 08/13/10 at 4:52pm

    • 08/13/10 5:10pm

      Joe Jenkins says:

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

    • 08/13/10 5:57pm

      Joe Jenkins says:

      I add this to a custome link:

      <? phpechoget_option('blogname'); ?>


      After saving the menu, I end up with this:

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

    • 08/13/10 6:01pm

      Joe Jenkins says:

      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');?

    • 08/13/10 6:11pm

      Eddie Moya says:

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


    • 08/13/10 6:14pm

      Eddie Moya says:

      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.

  • avatar
    Last edited:
    08/13/10
    4:52pm
    powerflash says:

    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

This question has expired.





Current status of this question: Refunded