Skip to content

Instantly share code, notes, and snippets.

markkap / gist:00a730c2a388187d8befe7ec38c49a63
Created June 8, 2016 06:42
target the cpw_excerpt filter at a specific widget
View gist:00a730c2a388187d8befe7ec38c49a63
* 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
markkap / cpw_filter.php
Last active June 8, 2016 06:28
How to use the cpw_excerpt filter to add additional excerpt field to be used by the category posts widget
View cpw_filter.php
Plugin Name: Unique excerpt for Category Posts Widget
Plugin URI:
Description: Adds a meta box for all posts in which the user can edit the excerpt that will be displayed at the category posts widget
* Register meta box(es).