Return to Snippet

Revision: 10291
at December 16, 2008 11:53 by davebowker

Initial Code
<?php $quote = get_posts('post_type=page&showposts=1&meta_key=quote&orderby=rand'); foreach($quote as $post) : setup_postdata($post); ?>
				<li class="quote"><a href="<?php the_permalink(); ?>" title="Read the <?php the_title(); ?> case study"><?php echo get_post_meta($post->ID, "quote", true); ?></a>
				<em><?php echo get_post_meta($post->ID, "quote-author", true); ?></em></li>
			<?php endforeach; ?>

Initial URL

Initial Description
$quote -- name of function
post_type=page -- remove to query posts
orderby=rand -- random order
showposts=1 -- limit to 1 post

effect -- displays 1 random custom excerpt outside of the loop

Initial Title
Custom Wordpress query using custom fields outside the loop

Initial Tags
php, wordpress, query

Initial Language