WordPress.org

Plugin Directory

Test out the new Plugin Directory and let us know what you think.

Multiple Featured Images

Enables multiple featured images for all post types. Comes with a widget for displaying the featured images.

How do I register multiple new featured images?

Use the handy filter to add multiple featured images.

For expample:

    add_filter( 'kdmfi_featured_images', function( $featured_images ) {
        $args_1 = array(
            'id' => 'featured-image-2',
            'desc' => 'Your description here.',
            'label_name' => 'Featured Image 2',
            'label_set' => 'Set featured image 2',
            'label_remove' => 'Remove featured image 2',
            'label_use' => 'Set featured image 2',
            'post_type' => array( 'page' ),
        );

        $args_2 = array(
            'id' => 'featured-image-3',
            'desc' => 'Your description here.',
            'label_name' => 'Featured Image 3',
            'label_set' => 'Set featured image 3',
            'label_remove' => 'Remove featured image 3',
            'label_use' => 'Set featured image 3',
            'post_type' => array( 'page', 'post' ),
        );

        $featured_images[] = $args_1;
        $featured_images[] = $args_2;

        return $featured_images;
    });

How do I use a different size of the featured image?

Simply add the size to the function call:

    kdmfi_the_featured_image( 'featured-image-2', 'full' );

You can choose every size that WordPress knows.

How can I get the ID of the featured image?

With this function call you can get the ID:

    kdmfi_get_featured_image_id( 'featured-image-2' );

Note: Since a featured image has only one individual id, there is no option 'size' in this function call.

How can I get the URL of the featured image?

With this function call you can get the URL:

    kdmfi_get_featured_image_url( 'featured-image-2', 'full' );

Which functions do exist?

  1. If you need the ID only, use this function:

    kdmfi_get_featured_image_id( $image_id, $post_id );
    

    $post_id is optional, if you leave it out, the ID of the calling post is used.

  2. To get the URL of the image:

    kdmfi_get_featured_image_src( $image_id, $size, $post_id );
    

    $post_id is optional (see above); $size is optional and defaults to 'full'.

  3. To get the featured image in HTML as a string:

    kdmfi_get_the_featured_image( $image_id, $size, $post_id );
    

    Again, $size and $post_id are optional.

  4. To display the featured image directly:

    kdmfi_the_featured_image( $image_id, $size, $post_id ) {
    

    Again, $size and $post_id are optional.

  5. To check if the post has a featured image:

    kdmfi_has_featured_image( $image_id, $post_id ) {
    

    $post_id is optional. The function returns the id of the attachment if there's one and false if not.

Requires: 3.5 or higher
Compatible up to: 4.6.1
Last Updated: 2 weeks ago
Active Installs: 10,000+

Ratings

4.6 out of 5 stars

Support

1 of 3 support threads in the last two months have been marked resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

2 people say it works.
1 person says it's broken.

100,1,1 100,1,1
100,1,1 100,1,1
100,3,3 100,1,1
100,4,4
50,2,1
50,6,3
50,8,4
0,1,0
100,3,3
33,3,1
100,1,1
80,5,4
0,1,0
100,1,1 67,3,2