Add Number of Post Views

From IThemes Codex
Revision as of 15:47, July 22, 2013 by Elise (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This function relies on the wp-postviews plugin. Download, install, activate and configure the plugin. Then, to insert the number of postviews in your layout, add the following code at the end of your functions.php file (but before the closing ?>, if any).

Code

function my_insert_post_views() {

    ob_start();
    if( function_exists('the_views') ) { 
        the_views(); 
    }
    $post_views = ob_get_contents();
    ob_end_clean();
 
    return $post_views;

}
add_shortcode('insert-post-views', 'my_insert_post_views');

Usage

Insert the shortcode [insert-post-views] in your LoopBuddy layout where you want the number of post views to show up.


← Back to LoopBuddy Codex Home

Personal tools
Namespaces
Variants
Actions
iThemes Codex
Codex Navigation
Toolbox