WordPress Adding Multiple Feature Images for page and post

Do you need the multiple feature image for a page or a post? Then the WordPress MFI or Multiple Feature Image Plugin is right for you. You can get is from the link here. Please follow the following procedure.

  1. Download the Multiple feature Image Plugin and Install the plugin. [for installing the wordpress plugin visit here]. Click here to download the plugin. Or visit the link https://wordpress.org/plugins/multiple-featured-images/
  2. Activate the plugin
  3. Open the functions.php in your current theme folder, Which is wordpress installed Directory/wp-content/themes/[theme name] /functions.php
  4. Add the following code on the functions.php file.
    add_filter( 'kdmfi_featured_images', function( $featured_images ) {    
    $args = array(        
    'id' => 'featured-image-2',        
    'descsc' => 'Your description here.',        
    'label_namebel_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' ),    
    );    
    $featured_images[] = $args;    
    return $featured_images;
    });
  5. To display the feature image on your page just paste the following function on the template where ever you want to display.
    kdmfi_the_featured_image( 'featured-image-2', 'full' );

How to Enable Multiple Features Images in Posts?

To enable the multiple Features Images in the posts, all you need to do is to add a post option on the above install code, so it will works on the wordpress post also. the detailed code is below.

add_filter( 'kdmfi_featured_images', function( $featured_images ) {    
$args = array(        
'id' => 'featured-image-2',        
'descsc' => 'Your description here.',        
'label_namebel_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', 'post' ),    
);    
$featured_images[] = $args;    
return $featured_images;
});

More Multiple features images

Just to make sure to add multiple times with the changed more featured image ID

add_filter( 'kdmfi_featured_images', function( $featured_images ) {    
$args = array(        
'id' => 'featured-image-2',        
'descsc' => 'Your description here.',        
'label_namebel_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', 'post' ),    
);    
$featured_images[] = $args;    
return $featured_images;
});

add_filter( 'kdmfi_featured_images', function( $featured_images ) {    
$args = array(        
'id' => 'featured-image-3',        
'descsc' => 'Your description here.',        
'label_namebel_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;    
return $featured_images;
});

Fetch the multiple Image link only

The display code will fetch the image display img src code, for the case if you want to use for the background image or else purpose, the function will get the image link.

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

Don’t forget to comment if you need any more ideas or resources.

Filed under: Wordpress