This widget shows a number of articles from all knowledge bases based on their number of likes.
Widget Settings
Simply go to Appearance Widgets and drag and drop the widget to your desired location. The settings will ask you for the title and the number of articles to show.
Widget Output
The screenshot above shows the output of the widget.
Extending the Widget
The argument that goes inside theĀ WP_Query
instantiation is filtered. So you can change it from outside using a plugin. The usage is something like this.
/** * Modify the popular widget query parameters * * @see http://codex.wordpress.org/Class_Reference/WP_Query#Parameters * @param array $arg The default query parameters * @return array Modified query parameters. */ function my_popular_widget_ext( $arg ) { // Conditionally add the category parameter // for category archive pages // This will make the popular widget to show articles // only under the current category if ( is_category() ) { $arg['cat'] = get_query_var( 'cat' ); } return $arg; } add_filter( 'ipt_kb_popular_widget_query_args', 'my_popular_widget_ext' );
The widget class is located under /inc/class-ipt-kb-popular-widget.php
.