• Resolved torquegod

    (@torquegod)


    Hi Guys,

    Am trying to show the secondary image in my loop on my home page using the following code to first single out the post from a specific category, then retrieve the image from that post –

    <?php query_posts('showposts=1&category_name=featured'); ?>
    <?php if (class_exists('MultiPostThumbnails')
        && MultiPostThumbnails::has_post_thumbnail('post', 'secondary-image')) :
            MultiPostThumbnails::the_post_thumbnail('post', 'secondary-image'); endif; ?>

    [Please post code or markup snippets between backticks or use the code button.]

    But the image is not showing up. Any ideas why this could be?

    Cheers,

    Rich

    https://www.ads-software.com/extend/plugins/multiple-post-thumbnails/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter torquegod

    (@torquegod)

    anyone? I still have this problem ??

    I too am having this issue, but I am just using the basic code give with the Instructions on the Plugin page. Here’s my code:

    functions.php:

    if (class_exists('MultiPostThumbnails')) { new MultiPostThumbnails(array( 'label' => 'Secondary Image', 'id' => 'secondary-image', 'post_type' => 'page' ) ); }

    loop:

    <?php if (class_exists('MultiPostThumbnails')
    	    && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image')) :
    	        MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image'); endif; ?>

    I have also tried changing ‘post’ to ‘page’ and nothing is working. I am using v3.3.1. Any ideas?

    Anyone get this to work with WP 3.3.1 ?

    I am having the same issue. The meta-box and set image both appear and seem to function properly, however, I cannot get the image to display in my template using the suggested code:

    <?php if (class_exists('MultiPostThumbnails')
    	    && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image')) :
    	        MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image'); endif; ?>

    I solved my issue by using this plugin instead:

    https://www.ads-software.com/extend/plugins/attachments/

    Never did get the Multi-Post Thumbs to work, but this one works for me like a charm!

    Thank you @gaberosser,

    The Attachments plugin looks promising for use in other projects. I really like this featured image functionality to make it really simple for a client to choose a Page Header Image on a page by page basis.

    What I have discovered is that the output does not work outside of the loop, which is where my page header resides. When I placed the template code within the loop it pulls in the image. Now, I have to figure out how to get the image when outside of the loop.

    I’ve tried this but cannot get it to work, still learning PHP. Does anyone know how I can properly call the MultiPostThumbnail when outside of the loop? Here is what I am trying in my template:

    <?php get_header(); ?>
    
    <div id="content" class="clear">
    
    <?php global $wp_query;
    $postid = $wp_query->post->ID;
    $post_type = get_post_type($postid);
    get_post($postid) ;?>
    
    <div id="page-header">
    <?php
    if (class_exists('MultiPostThumbnails')
    && MultiPostThumbnails::has_post_thumbnail($post_type, 'page-header-image')) :
    MultiPostThumbnails::the_post_thumbnail($post_type, 'page-header-image', NULL, 'Page Header');
    else : ?><img src="https://myblog.com/images/fallback-image.jpg" height="200" width="936" alt="San Francisco Skyline"/>
    <?php endif; ?>
    </div>
    
    <?php wp_reset_query(); ?>
    
    <div id="main-content">
    
    <div id="breadcrumbs"><?php if ( function_exists('yoast_breadcrumb') ) { yoast_breadcrumb();} else { the_breadcrumb();} ?></div>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!--Page or Post Content-->
    
    <?php endwhile; endif; ?>
    
    </div><!--END #main-content -->
    
    <?php get_sidebar(); ?>
    
    </div><!--END #content -->
    
    <?php get_footer(); ?>

    I’ve finally got this working the way I had planned. Here is how I am implementing this plugin in my theme to have a different page header image on each ‘post/page/custom post’ with a fallback image if not specified:

    In functions.php:

    add_image_size( 'Page Header', 936, 200, true ); 
    
    if (class_exists('MultiPostThumbnails')) {
        $types = array('post', 'page', 'tribe_events');
        foreach($types as $type) {
            new MultiPostThumbnails(array(
                'label' => 'Page Header Image',
                'id' => 'page-header-image',
                'post_type' => $type
                )
            );
        }
    }

    I’ve altered my original query and specified the post ID in the output according to a solution in a previous thread by ‘brubrant’ which can be found here: https://www.ads-software.com/support/topic/plugin-multiple-post-thumbnails-display-thumbnails-outside-loop

    In the post/page/custom post template:

    <?php global $wp_query;
    $postid = $wp_query->post->ID;
    $posttype = get_post_type($postid); ?>
    
        <div id="page-header">
    	<?php
    	if (class_exists('MultiPostThumbnails')
    	    && MultiPostThumbnails::has_post_thumbnail($posttype, 'page-header-image', $postid)) :
    	        MultiPostThumbnails::the_post_thumbnail($posttype, 'page-header-image', $postid, 'Page Header');
        	else : ?><img src="https://myblog.com/images/fallback-image.jpg" height="200" width="936" alt="San Francisco Skyline"/>
    	<?php endif; ?>
        </div>
    
        <?php wp_reset_query(); ?>
    
    <!-- STANDARD PAGE OR POST TEMPLATE WITH LOOP -->
    Plugin Author Chris Scott

    (@chrisscott)

    FYI, it would be a little cleaner to use get_queried_object_id() to get the post ID.

    Thank you Chris.

    Has anyone got this working in 3.3.2 or am I doing it wrong? When installing the plugin I don’t even get custom fields showing up in the backend. I’ve gone through the documentation and everything….

    Thanks for all the info above, pretty much all I could find on the subject right now.

    Plugin Author Chris Scott

    (@chrisscott)

    @ross.edman can you post your code where you register the thumbnails in functions.php?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Multiple Post Thumbnails] Secondary thumbnail not showing’ is closed to new replies.