Show Random Posts Custom Fields
-
Hi there everyone. I have searched for this and found stuff all around what I am looking for, but nothing on this exact thing, so hopefully someone will be able to help.
I have a section of my home page that brings in the latest post from a certain category. Only I have got it showing the not post, but instead I have it showing a field from the custom fields. This field is an image.
So I have an image from the latest posts custom field, which I have called ‘Thumbnail’ in a certain category showing on the home page.
What I want to do is to randomize this, so that every time a visitor goes to the home page it will show a random custom field image from a post in a specific category.
Below is the code that I am using to generate latest post from a specific category and show the custom field called Thumbnail. Perhaps this could be adapted slightly to randomize the post shown.
<?php $recent = new WP_Query("cat=1&showposts=1"); while($recent->have_posts()) : $recent->the_post();?> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_content_limit(200, ""); ?></a><div style="clear:both;"></div> <?php endwhile; ?>
Thanks
- The topic ‘Show Random Posts Custom Fields’ is closed to new replies.