Pages

Wednesday, August 29, 2012

How to add multiple Featured Images for each page/posts in wordpress?

For adding multiple featured images for pages or posts need to follow below steps.

1. Install the plugin Multiple Featured Images

2. Add the below code to functions.php

a. For adding Featured images to pages..

if( class_exists( 'kdMultipleFeaturedImages' ) ) {

        $args = array(

                'id' = 'featured-image-2',



                'post_type' = 'page',      // Set this to post or page

                'labels' = array(

                    'name'      = 'Featured image 2',

                    'set'       = 'Set featured image 2',

                    'remove'    = 'Remove featured image 2',

                    'use'       = 'Use as featured image 2',

     'width'  = 270,

     'height' = 102,

                )

        );

        new kdMultipleFeaturedImages( $args );

}

Here you can customize the functions. If you want add more featured images just increase the number (In our example 'Featured image 2' made 'Featured image 3') and increase the numbers in the total.

b. For adding Featured images to posts..

if( class_exists( 'kdMultipleFeaturedImages' ) ) {

        $args = array(

                'id' = 'featured-image-2',

                'post_type' = 'post',      // Set this to post or page

                'labels' = array(

                    'name'      = 'Featured image 2',

                    'set'       = 'Set featured image 2',

                    'remove'    = 'Remove featured image 2',

                    'use'       = 'Use as featured image 2',

     'width'  = 270,

     'height' = 102,

                )

        );

        new kdMultipleFeaturedImages( $args );

}

4. For displaying featured images copy the below code wherever we want to display.

If want to display more images increase the numbers like 'featured-image-2' to 'featured-image-3'

1 comment: