the short question:
I have this tag:
<?php include( TEMPLATEPATH . '/cat-4-feat-3.php' ); ?>but I want to make the last number of the page's path random.
do you know the code I can use?
the question explained:
I'm trying to solve a simple problem, just a matter of syntax probably but I don't know php and I'm learning now to use wordpress' tags..
so, I had to display randomly 4 different columns in a page, but in the column there's a div containing an image and a title with a link to a post, so things got a little complicated and I figured including a php template was a good solution.
Let's say I created 3 php pages named cat-4-feat-1.php , cat-4-feat-2.php , cat-4-feat-3.php
in which the code is:
<div class="box_pict"> <?php query_posts('p=20'); ?> <?php while (have_posts()) : the_post(); ?> <a id="pict_featured_3" href="<?php the_permalink() ?>" title="<?php the_title(); ?>"> <img class="c" src="http://localhost/wordpress/wp-content/uploads/2009/07/featured_1.jpg" /> <p id="post_37"> inspiration 4 </p> </a> <?php endwhile; ?> </div>
(obviously the post id and the image number change every time)
and I included the template in my page with:
<?php include( TEMPLATEPATH . '/cat-4-feat-3.php' ); ?>
but I need to modify that path with a function to make the number random.
I've seen using something like this:
<?php echo(rand(1,5)); ?>but I don't know how to use it in this situation coz I'm not familiar with php language.
can you help?
thank you guys, much appreciated.