Function Reference: geodir_sc_popular_post_category
Summary
The geodirectory popular post category shortcode.
Description
This implements the functionality of the shortcode for displaying popular post category.
Global Values
- $geodir_post_category_str
- (string) (required) The geodirectory post category.
- Default: None
Package
GeoDirectory
Parameters
- $atts
- (array) (required) {
Attributes of the shortcode. @type string $before_widget HTML content to prepend to each widget’s HTML output. Empty. @type string $after_widget HTML content to append to each widget’s HTML output. Empty. @type string $before_title HTML content to prepend to the title when displayed. Empty. @type string $after_title HTML content to append to the title when displayed. Empty. @type int $category_limit Number of categories to display. 15. @type string $title Widget title. Empty. @type string $default_post_type Default post type. Empty. @type bool $parent_only True to show parent categories only. }.- Default: False
Return Values
- (string)
- Popular post category HTML.
Change Log
Since: 1.0.0
1.5.1 Added default_post_type parameter.
1.6.9 Added parent_only parameter.
Source File
geodir_sc_popular_post_category() is located in geodirectory_shortcodes.php [Line: 732]
Source Code
function geodir_sc_popular_post_category($atts)
{
ob_start();
global $geodir_post_category_str;
$defaults = array(
'category_limit' => 15,
'category_restrict' => false,
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
'title' => '',
'default_post_type' => '',
'parent_only' => false,
);
$params = shortcode_atts($defaults, $atts, 'popular_post_category');
$params['category_limit'] = absint($params['category_limit']);
$params['default_post_type'] = gdsc_is_post_type_valid($params['default_post_type']) ? $params['default_post_type'] : '';
$params['parent_only'] = gdsc_to_bool_val($params['parent_only']);
geodir_popular_post_category_output($params, $params);
$output = ob_get_contents();
ob_end_clean();
return $output;
}