Skip to content

Instantly share code, notes, and snippets.

@mrwweb
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrwweb/cb48eb0700aebc45c273 to your computer and use it in GitHub Desktop.
Save mrwweb/cb48eb0700aebc45c273 to your computer and use it in GitHub Desktop.
Examples of the fpw_post_types filter in Feature a Page Widget 2.0. By default, the widget will allow Pages and Posts to be featured.
<?php
/**
* add a post type that can be featured in the Feature a Page Widget
*
* Any post types added via this filter automatically have support added for excerpts and featured images
*
* This example adds the ability to feature the "book" post type
*
* @param $post_types array array of post_type slugs that can be featured with the widget
*/
add_filter( 'fpw_post_types', 'fpw_add_post_type_to_feature' );
function fpw_add_post_type_to_feature( $post_types ) {
$post_types[] = 'book';
return $post_types;
}
/**
* remove a post type that can be featured in the Feature a Page Widget
*
* This example removes the [now default] ability to feature the Post post type
*
* @param $post_types array array of post_type slugs that can be featured with the widget
*/
add_filter( 'fpw_post_types', 'fpw_remove_post_type_to_feature' );
function fpw_remove_post_type_to_feature( $post_types ) {
return array_diff( $post_types, array( 'post' ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment