Created
June 8, 2016 06:42
-
-
Save markkap/00a730c2a388187d8befe7ec38c49a63 to your computer and use it in GitHub Desktop.
target the cpw_excerpt filter at a specific widget
This file contains 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
/** | |
* This gist shows how to use the "number" attribute of a widget object to target a specific widget | |
* You can find the number associate with a specific widget by inspecting the generated HTML for it, | |
* it is the suffix of the id attribute of the element wrapping the widget | |
* | |
* @param string $excerpt The current excerpt | |
* @param WP_Widget $widget the widget object from which it is possible to get the information of its type an dID number | |
* @param int $length the configured request length for an excerpt. A zero is passed if no value is actually configured | |
* | |
* @return the widget number appended to the excerpt | |
*/ | |
function cpw_excerpt_filter_wn($excerpt,$widget,$length) { | |
return $excerpt.' '.$widget->number; | |
} | |
add_filter('cpw_excerpt','cpw_excerpt_filter_wn',10,3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment