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.
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
<?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