• Resolved Bill Erickson

    (@billerickson)


    Great plugin!

    Right now it looks like it adds the column to any post type that supports featured images, and adds featured image support to post and page.

    I recommend creating a filtered array, $post_types, so developers can specify exactly where it shows up.

    $post_types = array();
    if( post_type_supports( 'post', 'thumbnail' ) $post_types[] = 'post';
    if( post_type_supports( 'page', 'thumbnail' ) $post_types[] = 'page';
    $post_types = apply_filters( 'featured_image_column_post_types', $post_types );

    That way, if I want to limit it to just my “rotator” post type, I can drop this in the functions.php file:

    function be_featured_image_columns( $post_types ) {
    	return 'rotator';
    }
    add_filter( 'featured_image_column_post_types', 'be_featured_image_columns' );

    http://wordpress.org/extend/plugins/featured-image-column/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Austin

    (@austyfrosty)

    Great idea. Which function would I drop that into?

    Thread Starter Bill Erickson

    (@billerickson)

    I’d recommend creating a separate function in the class:

    function included_post_types( $post_type ) {
    	$post_types = array();
    	if( post_type_supports( 'post', 'thumbnail' ) $post_types[] = 'post';
    	if( post_type_supports( 'page', 'thumbnail' ) $post_types[] = 'page';
    	$post_types = apply_filters( 'featured_image_column_post_types', $post_types );
    	if( in_array( $post_type, $post_types )
    		return true;
    	else
    		return false;
    }

    Then, everywhere you’re checking to see if the current post type supports thumbnails, replace it with this function. For example, at the top of columns(), change this:

    if ( !post_type_supports( $post_type, 'thumbnail' ) )
    	return;

    To this:

    if( !self::included_post_types( $post_type ) )
    	return;

    This is all untested though

    Plugin Author Austin

    (@austyfrosty)

    I’ll play around with this.

    The power of community:) I just learned of your plugin and I’m agreed…GREAT idea!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Featured Image Column] filter for post types’ is closed to new replies.