WordPress Multiple Thumbnail Support

I am searching this solution for sometimes, like how to make post/custom post featured image to be multiple. Lucky i found some insight, so let’s just check it out.

Edit functions.php at active theme’s folder and add the code below :


/* SETTING ENABLE THUMBNAIL SUPPORT */
add_theme_support( 'post-thumbnails' );

Go to this link https://wordpress.org/plugins/multiple-post-thumbnails/ and download it. After finished downloading the plungin, extract it and only copy multi-post-thumbnails.php, media-modal.js and multi-post-thumbnails-admin.js to your theme’s directory like the example below :


> your-themes
 > libraries
  - multi-post-thumbnails.php
  > js
   - multi-post-thumbnails-admin.js
   - media-modal.js

Edit multi-post-thumbnails.php at active theme’s libraries folder and change the code below :


Find all : wp_enqueue_script, Example : wp_enqueue_script( "mpt-featured-image", $this->plugins_url( 'js/multi-post-thumbnails-admin.js', __FILE__ ), array( 'jquery', 'media-upload' ) );
Replace it with : wp_enqueue_script( "mpt-featured-image", get_template_directory_uri()."/libraries/". 'js/multi-post-thumbnails-admin.js', array( 'jquery', 'media-upload' ) );	

*You need to change the queque script from plugin to theme directory

Edit functions.php at active theme’s folder and add the code below add_theme_support code :


/* SET MULTIPLE THUMBNAILS SUPPORT */
if (class_exists('MultiPostThumbnails')) {
    new MultiPostThumbnails(array(
	        'label' => '2nd Feature Image',
	        'id' => 'feature-image-2',
	        'post_type' => 'post'
        )
    );
};

Edit functions.php at active theme’s folder and add the code at the top of all code :


require_once('libraries/multi-post-thumbnails.php');

For the output you can try this code :


MultiPostThumbnails::the_post_thumbnail('post', 'feature-image-2');

Leave a Reply

Your email address will not be published. Required fields are marked *