Created
September 21, 2018 11:33
-
-
Save marcelo2605/acaf7c536bba2d1a7e8d6bff46a8c3f1 to your computer and use it in GitHub Desktop.
Filter "Recent posts" widget to show only posts that have the same category that current post.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add parameter to Recent post widget | |
*/ | |
add_filter('widget_posts_args', function($params){ | |
$categories = get_the_category(get_the_ID()); | |
$params['cat'] = $categories[0]->term_id; | |
return $params; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment