Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Christiaan Conover

    (@cconover)

    Support for this is coming in an upcoming release. Thanks for requesting it!

    Would love to see this implemented too! Great work!

    Looking at MetaBox.php it seems harder to add this to custom post types without requiring an admin screen for users to tick off the CPTs they want this to appear on.

    I have found some code for detecting a CPT:
    https://wordpress.stackexchange.com/questions/6731/if-is-custom-post-type

    Here it is:

    To test if a post is any custom post type, fetch the list of all not built-in post types and test if the post’s type is in that list.

    As a function:

    /**
     * Check if a post is a custom post type.
     * @param  mixed $post Post object or ID
     * @return boolean
     */
    function is_custom_post_type( $post = NULL )
    {
        $all_custom_post_types = get_post_types( array ( '_builtin' => FALSE ) );
    
        // there are no custom post types
        if ( empty ( $all_custom_post_types ) )
            return FALSE;
    
        $custom_types      = array_keys( $all_custom_post_types );
        $current_post_type = get_post_type( $post );
    
        // could not detect current type
        if ( ! $current_post_type )
            return FALSE;
    
        return in_array( $current_post_type, $custom_types );
    }

    Usage:

    if ( is_custom_post_type() )
        print 'This is a custom post type!';
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Featured image caption on custom post types’ is closed to new replies.