Creating new featured post templates starts with registering a template function with the plugin and then implementing the way of displaying the post(s).

Register the new template with the plugin

To register a new template with the plugin you will have to hook to a filter called cfp_register_template.

This filter will pass as parameter an array or all registered templates to which you can add your own template.

/**
 * Add new templating function 
 * using plugin filter 'cfp_register_template'
 * @param array $templates
 */
function my_template_registration( $templates ){
    // give template a unique key
    $templates['my-template-name'] = array(
        // register a callback function that will be 
        // called when a featured post is displayed
        'output_callback' => 'my_template_output',
        'name' => 'My template',
    );   
    return $templates;
}
add_filter( 'cfp_register_template', 'my_template_registration' );

As you can see from the code, the callback function adds a new key to templates array and registers a callback function that will be called whenever your new template needs to be displayed and also a nice name for your template that will be displayed in all plugin interfaces in WordPress admin area.

Create the template output function

In step one, when we registered our new template, we specified a function name for output callback ( my_template_output ) so now it’s time to create the function that will output our template.

Please remember that when calling the template output function, the plugin will pass to it 4 parameters: the featured post object that should be displayed, the post terms/category for the taxonomy specified by the shortcode, the post featured image HTML returned by WordPress and the post featured image URL (in case you want a different output for the image).

/**
 * Template output function. The function is called by the plugin based 
 * on the registration of the template made using 
 * filter 'cfp_register_template'
 * 
 * @param object $post - the post being displayed
 * @param array $terms - the post terms
 * @param string/HTML $image - the HTML image code to display
 * @param string $image_url - the featured image URL
 */
function my_template_output( $post, $terms, $image, $image_url ){
    $output = <<<HTML
<div class="codeflavors-featured-post">
    {$image}
    <div class="cf-overlay">
        <div class="cf-inside">
            <h2>{$post->post_title}</h2>
            <p>{$post->post_excerpt}</p>            
        </div><!-- .cf-inside -->
    </div><!-- .cf-overlay -->
</div><!--end featured post-->
HTML;

    // always return, don't echo the output
    return $output;
}

Another important thing to notice is that you should always return the output, so don’t display anything into this function. Additionally, any of the CSS classes used above are just examples, you can use any CSS class you want.

Style the template output

To style the output, either place all CSS into your theme stylesheet or output the styling directly into the pages of your blog (by hooking to wp_print_styles action for example).