• Resolved omniafausta

    (@omniafausta)


    Hi,

    I am implementing the plugin Multiple Post Thumbnails into a website, and using it to give the client the option to put 3 images in the banner.

    So in the header I now have this code:

    <div id="banner">
    	<?php if (class_exists('MultiPostThumbnails')) : {
    		MultiPostThumbnails::the_post_thumbnail(
    			get_post_type(),
    			'feature-image1',
    			set_post_thumbnail_size( 265, 265, true )
    		);
    		MultiPostThumbnails::the_post_thumbnail(
    			get_post_type(),
    			'feature-image2'
    		);
    		MultiPostThumbnails::the_post_thumbnail(
    			get_post_type(),
    			'feature-image3'
    		);
    		}
    	endif; ?>
    </div>

    But what I would like, is to have the option to show 3 standard images if the MultiPostThumbs are not specified.
    Any tips on how to let the site know that nog images were chosen?

    The any option I see now is to set a backgroundimage for the banner div, that is covered with the featured images if they are picked… But I don’t think it is the most elegant option.

    Any advice is welcome, I know some php, but still a novice in php (pretty fluent in html and css, but my guess is this will need to be done in php…)

    Thanks!!

    https://ww.wp.xz.cn/plugins/multiple-post-thumbnails/

Viewing 1 replies (of 1 total)
  • Thread Starter omniafausta

    (@omniafausta)

    oh forgot to post that I found a way to solve this

    this is the code used now

    <?php
    	if ( MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'feature-image1') ) {
    		MultiPostThumbnails::the_post_thumbnail(
    			get_post_type(),
    			'feature-image1',
    			set_post_thumbnail_size( 265, 265, true )
    		);
    	}
    	else {
    		echo '<img src="' . get_stylesheet_directory_uri() . '/images/banner-standaard1.jpg" alt="banner" />';
    	}
    	if ( MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'feature-image2') ) {
    		MultiPostThumbnails::the_post_thumbnail(
    			get_post_type(),
    			'feature-image2',
    			set_post_thumbnail_size( 265, 265, true )
    		);
    	}
    	else {
    		echo '<img src="' . get_stylesheet_directory_uri() . '/images/banner-standaard2.jpg" alt="banner" />';
    	}
    	if ( MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'feature-image3') ) {
    		MultiPostThumbnails::the_post_thumbnail(
    			get_post_type(),
    			'feature-image3',
    			set_post_thumbnail_size( 265, 265, true )
    		);
    	}
    	else {
    		echo '<img src="' . get_stylesheet_directory_uri() . '/images/banner-standaard3.jpg" alt="banner" />';
    	}
     ?>
Viewing 1 replies (of 1 total)

The topic ‘if no multiple post thumbnails show something else…’ is closed to new replies.