Skip to content

Internal Shortcode | [Comment_Count]

EkoJr edited this page Jan 22, 2017 · 1 revision

Description

Adds the number of comments with a post/page.

Usage

[comment_count]

Return

(string) Amount of comments.

Examples/Sample

Example 1

[comment_count]

Returns

9

Source

File: advanced-post-list/includes/class/apl_shortcodes.php

/**
 * Post Comment Count Shortcode. 
 * 
 * Desc: Adds the Post Comment_Count, which displays the amount of comments
 * per post.
 * 
 * 1. Add to return Post Comment_Count.
 * 2. Return string.
 * 
 * @since 0.1.0
 * @version 0.4.0 - Changed to Class function, and uses WP's built-in
 *                  functions for setting default attributes & do_shortcode().
 * 
 * @param array $atts None.
 * @return string Post->Comment_Count.
 */
public function comment_count($atts)
{
    //INIT
    $atts_value = shortcode_atts( array(), $atts, 'comment_count');
    $return_str = '';
    
    //STEP 1
    $return_str .= $this->_post->comment_count;
    
    //STEP 2
    return $return_str;
}

Additional Resources

Clone this wiki locally