Jump to content

need some help with (rand)


chayton

Recommended Posts

I'm a PHP noob but I'm trying to learn - I used to do some Director/lingo coding so I'm not completely moronic, but I'm still getting a grip on PHP syntax and how everything works, so if anyone can give me some help with this, I'd appreciate it.

 

First let me explain what I'm doing - I have a wordpress blog and on my home page I'm displaying a gallery using the "links" section of wordpress and using images for it. I've currently got code like this:

 

<?php $gallery = array(

'category' => 104,

'order' => 'ASC',

'orderby' => 'name',

'categorize' => false,

'title_li' => false,

'before' => false,

'after' => false,

'show_images' => true,

'category_before' => false,

'category_after' => false,

); ?>

 

<?php wp_list_bookmarks($gallery); ?>

 

and it works great, but I'd like to expand it. Right now it takes everything I have in the links and displays them so I have to physically limit the amount of links I have. What I'd like to be able to do is enter all the links, then have the code grab a number (16) entries at random, and display only those - and display them randomly rather than by name. I know it's probably really easy but everything I've tried seems to break it, so I know I'm just not 'getting it' Do I need to get this first array and then use the (rand) function on it? Or can this code be modified to do the rand as is?

 

thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/199022-need-some-help-with-rand/
Share on other sites

Thanks - the rand function works. But how can I make it so it only picks a certain number of the total items? For example in this array there are 50 items - I only want to display 16 randomly chosen items every time. Is that possible? Sorry if I'm missing something obvious.... :-[

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.