What it changes
This example adds each popular post’s category links to the output filtered by Top 10. WordPress supplies the category-list markup.
What to change
Change the separator passed to get_the_category_list() if you do not want comma-separated links. Check the result with your selected Top 10 output style. The snippet adds no CSS of its own.
Requirements
- Top 10
- Top 10 must be active and rendering a popular-posts list.
Source
top-10/outputs/tptn-add-categories.php<?php
/**
* Plugin Name: Top 10 - Add Categories
* Plugin URI: https://webberzone.com/plugins/top-10/
* Description: Adds the categories to the items in the popular posts list.
* Author: Ajay D'Souza
* Author URI: https://webberzone.com
* Version: 1.0
*
* @package Top_Ten
* @license GPL-2.0+
*/
/**
* Add categories to the list items.
*
* @param string $output Formatted list item with link and and thumbnail.
* @param object $result Object of the current post result.
* @param array $args Array of arguments.
*
* @return string Output variable with categories added
*/
function tptn_list_cats( $output, $result, $args ) {
$categories = get_the_category_list( ', ', '', $result->ID );
$output .= ' ' . $categories;
return $output;
}
add_filter( 'tptn_list', 'tptn_list_cats', 10, 3 );Details
- Type
- Plugin
- Last updated
- GitHub
- Source · Edit companion · History