Skip to content

Instantly share code, notes, and snippets.

@markkap
markkap / gist:00a730c2a388187d8befe7ec38c49a63
Created Jun 8, 2016
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
markkap / cpw_filter.php
Last active Jun 8, 2016
How to use the cpw_excerpt filter to add additional excerpt field to be used by the category posts widget
View cpw_filter.php
<?php
/*
Plugin Name: Unique excerpt for Category Posts Widget
Plugin URI: http://mkrdip.me/category-posts-widget
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).
*/