Yet Another Featured Posts Plugin (YAFPP) - Documentation

Created by Jon Raasch

YAFPP is a WordPress plugin that provides an easy interface for featuring specific posts. YAFPP returns the posts either as formatted data, an array or the query for the_loop()

Download Yet Another Featured Posts Plugin (YAFPP)

Basic Setup

First download YAFPP and upload it to your site's wp-content/plugins/ directory.

Next login to your WordPress admin section, and navigate to 'Plugins' and active YAFPP.

Go to your posts listing in the WordPress admin panel ( Posts > Edit ). Here click on the stars on the right side of the post listings to feature or unfeature posts.

In your site's template include <?php get_featured_posts(); ?> anywhere that you want to display the post listing.

Listing display options can be configured in the WordPress admin panel - Settings > Featured Posts (YAFPP). Here you can select which aspects of the post you want to show in the listing, along with the maximum number of posts to display, and the max length for the excerpt if displayed.

You can also set which user levels can feature / unfeature posts. By default this is set so the editor and admin can only feature / unfeature posts, but you might consider allowing authors to do so.


Output Options

For advanced users, YAFPP offers some useful output options which can be passed to the get_featured_posts() function like so:

<?php get_featured_posts(array( 'method' => 'return')); ?>

In this example we are setting YAFPP to return the formatted list of featured posts, as opposed to echoing it out like it does by default.

Additionally you can pass 'arr' to get YAFPP to return an array of data for the featured posts. The format for this array is a list of the posts, each of which contain these keys:

<?php 

array(
    'id'      => '', // id of the post
    'title'   => '', // title of the post
    'excerpt' => '', // excerpt of the post
    'url'     => '', // the post permalink
    'image'   => '', // an array of data for a YAPB image, if it exists
    'author' =>  '', // the post's author
); 

?>

Finally you can pass 'the_loop' to cause YAFPP to alter the query used by WordPress' the_loop(). This will make WordPress loop through the featured posts the next time it goes through the loop:

<?php

get_featured_posts(array('method' => 'the_loop'));

 while (have_posts()) : the_post();
//whatever you want in here
endwhile;

?>

Additionally, the original query is still preserved when using this method. If you need to call the original loop (without YAFPP's interference) just go through the loop a second time:

<?php

get_featured_posts(array('method' => 'the_loop'));

 while (have_posts()) : the_post();
//whatever you want to do with the featured posts
endwhile;

 while (have_posts()) : the_post();
//whatever you want to do with the original loop
endwhile;

?>

Options List for get_featured_posts()

Here is the complete array of options you can pass to YAFPP:

<?php

get_featured_posts(array(
    'before' => '<li>',               // HTML show before each featured listing
    'after'  => '</li>',              // HTML after each featured listing
    'method' => 'echo',               // output method - can also be 'return' and 'the_loop'
    'excerpt_length' => 150,          // length of the post excerpt
    'max_posts' => 5,                 // max number of featured posts - 0 for unlimited
    'no_posts_text' => 'No Featured', // text to show when there are no featured posts
));

?>

It should be noted that excerpt_length, max_posts and no_posts_text can all be set from the WordPress control panel—however they will be overwritten if they are set using get_featured_posts().


Advanced use of YAFPP

Coming Soon...


Upcoming enhancements

User cannot feature/unfeature a post that they cannot edit

Unpublished posts cannot be featured/unfeatured


License Info

Yet Another Featured Posts Plugin (YAFPP) is released under the FreeBSD license:

Copyright (c) 2009 Jon Raasch (http://jonraasch.com/)

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY JON RAASCH 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JON RAASCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of Jon Raasch, who is the man.



Make A Donation