13 July 2020

How to create second select featured image in add product page in woocommerce


Note:-> Enqueue these file and get from Multiple Post Thumbnails plugin. After getting these files then you can deactivate plugin.

Page in function.php file

function enqueue_files(){


wp_enqueue_script( 'jquery', get_stylesheet_directory_uri() . '/js/jquery.min.js');
wp_enqueue_style( 'custom-elementor-style', get_stylesheet_directory_uri() . '/widgets/custom-elementor-style.css');

 wp_enqueue_script("featured-image-custom", get_stylesheet_directory_uri(). '/js/multi-post-thumbnails-admin.js');
 


}


add_action("wp_enqueue_scripts","enqueue_files");

add_theme_support( 'post-thumbnails' );
add_image_size( 'feature-image', 960, 500, true );



// Define additional "post thumbnails". Relies on MultiPostThumbnails to work
if (class_exists('MultiPostThumbnails')) {
    new MultiPostThumbnails(array(
        'label' => '2nd Feature Image',
        'id' => 'feature-image-2',
        'post_type' => 'product'
        )
    );
   

};



get image with this code which i mentioned below.

<?php MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'feature-image-2', NULL); ?>

No comments:

Post a Comment

How to add re-captcha v3 on all Elementor forms using coding?

 Add re-captcha v3 on all Elementor forms using coding add_action('wp_footer',function(){     ?> <script src="https://www...