Plugin Release: Featured Content

I recently had a client request an easy way to mark content on their site as Featured. They wanted something consistent, usable and simple that could be applied to pages, posts, events and more.

I wrote a simple plugin for the client and realized that it would probably be helpful for other people – I’m probably not the only one looking to do something like this, right? Anyways, that’s how the Featured Content plugin came about. You can go ahead and download it from the WordPress plugin repository.

There is a simple checkbox on the content editing screen that you can toggle before you save and update your content.

Editing Checkbox

Also, there is a link in the content actions area of the management screen that you can click to Feature or Unfeature your content.

screenshot-2

After marking content as featured, you’ll need to change your theme to make it use the functionality that you’ve specified. You can either use the template tag to display style or markup for featured content or query for only featured or non-featured content. Here’s some examples:

Different Display for Featured Content

<?php

while(have_posts()) {
	the_post();

	echo '<h2>';

	if(featured_content_is_featured_content()) {
		echo 'Featured: ';
	}
	the_title();

	echo '</h2>';
}

Querying for Featured or Non-Featured Content

<?php

$featured_posts = new WP_Query(array('is_featured' => 'yes', 'post_type' => 'post'));

$non_featured_posts = new WP_Query(array('is_featured' => 'no', 'post_type' => 'post'));

If you find this useful or have any questions, please let me know!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>