Hello everyone.
Before I start, I'm still learning WordPress and PHP so please be gentle :)
I thought I'd try to get my head around custom taxonomies. I'm using the plugin Custom Post Types UI to create a post type of 'Directory Listing', a custom taxonomy of Directory Category, some terms inside this category, therefore looking like this:
Directory Listing (custom post type)
> Directory Category (custom taxonomy)
> Children and Family (term)
> Entertainment (term)
> Motoring (term)
> Pets (term)
I have the following page template:
loop-page-directory.php (also with a page-directory.php) the former containing only the following code:
<?php wp_tag_cloud( array( 'taxonomy' => 'directory-category', 'format'=>'list', 'smallest' => 16, 'largest' => 16, 'unit' => 'px' ) ); ?>
This lists all the terms above Children, Entertainment, Motoring, Pets; I can click each item and it takes me to the business listings I've added with that term. This is housed on a page template called:
loop-taxonomy-directory-category.php (I've created a corresponding taxonomy-directory-category.php). The former contains the following code:
<!-- Business and Organisation Listings Page -->
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class="entry-content">
<!-- Custom Fields -->
<div id="wrapper-dirlist">
<div class="dirlist-brand"><?php echo get_post_meta($post->ID, 'bizbrand', true); ?></div>
<div class="dirlist-content">
<div class="dirlist-title"><?php the_title(); ?></div>
<div class="dirlist-address"><?php echo get_post_meta($post->ID, 'dirlist-address', true); ?></div>
<div class="dirlist-description"><?php the_content(); ?></div>
<div class="dirlist-contactinfo">
<li><?php echo get_post_meta($post->ID, 'dirlist-phone', true); ?></li>
<li><?php echo get_post_meta($post->ID, 'dirlist-email', true); ?></li>
<li><?php echo get_post_meta($post->ID, 'dirlist-website', true); ?></li>
<li><?php echo get_post_meta($post->ID, 'dirlist-document', true); ?></li>
<li><?php echo get_post_meta($post->ID, 'dirlist-voucher', true); ?></li>
</div>
</div>
</div><!-- .entry-content -->
</div>
<?php endwhile; // end of the loop. ?>
This lists the items perfectly fine and they are styled okay with CSS.
My problem and difficulty arises when I try to order the listed items randomly, so that my most recently added listing is not on top, but that all listings have a chance, through random ordering, to be on top.
I've tried loads of things yesterday (this was my brick wall) including various pieces of code with 'orderby' => 'rand' in them, but I'm clearly not understanding this.
Any help and advice is welcome.
Thank you.
Gavin.